Written and maintained by CASRAI Editorial Board
Last updated
Who this is for: a researcher, analyst or student who has been handed a SAS program (or told to write one) and needs to know what the language is, what its two building blocks do, and how to run and read a first program. After reading, you should be able to write a short program that points to your data, creates a working copy, prints it, summarises it and checks the Log.
What is SAS in coding, and what language does it use?
SAS is both a software system and the programming language you use inside it. There is no separate “SAS language” to install; you write SAS code (also called a SAS program) in an editor and submit it to the SAS system, which runs it and reports what happened. A SAS program is built from two kinds of steps, and that is the single most useful fact for a beginner:
- A DATA step reads, creates or changes a data set. UCLA’s OARC SAS tutorial states that data steps “always begin with a DATA statement.”
- A PROC step (procedure step) runs a ready-made procedure such as printing, summarising or tabulating a data set. The same tutorial states that PROC steps always start with a PROC statement.
A third piece, the LIBNAME statement, tells SAS where your data files live. The tutorial describes it as opening a directory at the location where your SAS data files are stored; the name you give it is called a libref.
The SAS Help Center’s SAS Programmer’s Guide: Essentials organises the language the same way: syntax rules (words, names, variables, expressions, operators, dates, comments), accessing data (libraries, engines, data sets, raw data), manipulating data (grouping, WHERE, loops and conditionals, combining data, arrays, debugging) and creating output. It also has an appendix titled “Understanding How the DATA Step Works.” SAS is also used in research analysis; for what the platform covers and how it compares with other packages, see SAS statistical software: platform guide.
Is SAS coding hard?
Editorial view: the syntax is regular, and the main early difficulty is not logic but discipline. Every statement ends with a semicolon, every step needs a recognised starting keyword, and SAS reports problems in a separate Log window rather than stopping with a friendly message. The troubleshooting table below covers the mistakes that cost beginners the most time. People who already know another statistical language usually find that the DATA step and its row-by-row processing is the concept that needs the most practice; the Help Center appendix on how the DATA step works is written for exactly that.
Is SAS still relevant in 2026?
Yes for particular settings, and it depends on where you work. SAS remains documented and maintained: the SAS Programmer’s Guide: Essentials in the SAS Help Center was updated on 2026-08-14 (read 2026-11-07). Whether you should learn it is a workplace question, not a popularity contest. It is common to meet SAS code in established analysis groups and in regulated clinical work; for the clinical-data standards context see CDISC standards for FDA submissions. If you are choosing a tool for a new project with no inherited code, compare it directly in R vs SAS or SAS vs SPSS for research analysis.
Install or access
Access normally comes through an institution or through SAS itself; use the SAS website and the SAS Help Center as the only sources for what is currently offered and what each product includes. This page does not state prices. Once you can open a SAS session, the editor accepts the code below. The OARC tutorial describes the Editor window as the place where you enter, edit, submit and save SAS programs, the Log window as showing messages about submitted programs (successful execution, errors or warnings), and the Results Viewer as showing HTML results from executed procedures. In SAS 9.4 the tutorial says the default output format is HTML; before SAS 9.3 the default destination was listing output.
If you use a point-and-click front end rather than typing code, see SAS Enterprise Guide.
Your first SAS program, step by step
The program below uses placeholder names (mylib, survey, income, region, id); replace them with a folder and data set of your own. The statement forms are the ones shown in the OARC tutorial and the Help Center structure.
- Point SAS at your data. Assign a library with a LIBNAME statement. Change the quoted path to your folder (the tutorial’s example is
LIBNAME idre 'C:';). - Create a working copy with a DATA step. Start with DATA, name the new data set, and bring in the existing one with SET. A one-level name such as
work_copymakes a temporary data set; a two-level name such asmylib.work_copywrites a permanent one into the library. The tutorial shows both forms (DATA new; SET idre.charities;andDATA idre.new; SET idre.charities;). - Look at the rows. Run PROC PRINT with the DATA= option; add
(OBS=5)after the data set name to limit the rows and a VAR statement to choose columns. - Summarise a numeric variable. Run PROC MEANS with statistic keywords on the PROC statement and a VAR statement naming the variable.
- Tabulate a categorical variable. Run PROC FREQ with a TABLES statement.
ORDER=FREQsorts the table by frequency. - Release the library when finished with
LIBNAME mylib CLEAR;, then read the Log.
LIBNAME mylib 'C:yourfolder'; /* 1. assign the library */
DATA work_copy; /* 2. new temporary data set */
SET mylib.survey;
RUN;
PROC PRINT DATA=work_copy (OBS=5); /* 3. first five rows */
VAR id region income;
RUN;
PROC MEANS DATA=work_copy MEAN MIN; /* 4. summary statistics */
VAR income;
RUN;
PROC FREQ DATA=work_copy ORDER=FREQ; /* 5. frequency table */
TABLES region;
RUN;
LIBNAME mylib CLEAR; /* 6. release the library */
To filter rows, add a WHERE statement inside a step; in the tutorial, PROC PRINT DATA=idre.sales; WHERE Country='AU'; RUN; prints only the rows where Country is AU, and WHERE Country IN ('AU', 'US'); keeps either value. Text comparisons use quoted values.
Output and how to read it
- PROC PRINT shows the rows you asked for, so use it to confirm the data set was read as intended before running any analysis.
- PROC MEANS reports the statistics you named. The tutorial notes that the keyword is
MEAN: an unrecognised option such as “average” is flagged by SAS. - PROC FREQ counts how often each value of the TABLES variable occurs; with
ORDER=FREQthe most common values come first. - The Log is a separate window listing messages about every submitted step: successful execution, errors and warnings. Read it after every run, before trusting any output. Output appearing does not by itself show that the program ran as you intended.
To send results to a file, the tutorial shows the Output Delivery System pattern: open a destination (for example ODS PDF FILE=...), run the procedure, then close it with ODS PDF CLOSE;. ODS statements are global and stay in effect until closed. For the wider output of one procedure, see PROC CONTENTS in SAS.
Troubleshooting
| Symptom | Likely cause | What to check |
|---|---|---|
| A procedure flags an option as not recognised | A misspelled or non-existent option or keyword | Read the Log message; the tutorial’s example is “average” rejected where MEAN works. |
SAS cannot find a data set such as mylib.survey |
The library was never assigned, the path in the LIBNAME statement is wrong, or the library was cleared | Run the LIBNAME statement first, check the quoted folder path, and do not run LIBNAME ... CLEAR; until you are finished. |
| A step seems to do nothing or the next step does not start | Missing semicolon or missing RUN; |
Every statement ends with a semicolon and the tutorial’s steps each end with RUN;. Check the Log for messages about the step. |
For anything not in the table, the SAS Help Center’s “Debugging” topic in the Manipulating Data section of the Programmer’s Guide is the first place to look.
Free alternatives
| Alternative | Use it when | On CASRAI |
|---|---|---|
| R | You are starting a new analysis with no SAS code to inherit and need to read SAS data sets anyway. | R vs SAS; How to load data into R (including SAS files) |
Frequently asked questions
What is SAS in coding?
SAS is a software system whose programs are written in the SAS language. A program is built from DATA steps, which create or change data sets, and PROC steps, which run procedures on them.
What coding language is used in SAS?
The SAS language itself. You write DATA and PROC steps, plus LIBNAME statements to locate data, in a SAS editor and submit them for execution.
Is SAS coding hard?
The statements are short and regular, but they must be exact. Most beginner problems are a missing semicolon, a missing RUN;, an unassigned library or a misspelled option, and the Log tells you which.
Is SAS still relevant in 2026?
SAS documentation was being updated in August 2026, and SAS code is common in established and regulated analysis settings. Choose it when your group already uses it; otherwise compare options first.
Sources
- UCLA Advanced Research Computing, OARC Statistical Methods and Data Analytics: SAS Programming Basics, read 2026-11-07.
- SAS Help Center: SAS Programmer’s Guide: Essentials (SAS Viya, updated 2026-08-14), contents read 2026-11-07.







