You don’t need to spend a whopping 6 months to learn SAS. Go through our 11-step SAS learning guide and turn yourself into a proficient SAS programmer in just 30 days.











Step 1: Get Access to SAS Studio on SAS OnDemand for Academics

Step 2: Learn SAS Interface
Before you start writing any code, you must first become familiar with the SAS interface.
Fortunately, SAS interface is fairly simple. Let’s take a look at each part of the interface below:
1. Coding Area

The coding area is located in the middle of the SAS Studio interface. This is where you enter your programming code.
2. Log Window

The LOG window shows the programming notes after you run the program. It provides information about the code execution and whether there is any issue with the program.
3. Results Window

The RESULTS window displays the report or analysis results when a certain procedure is compiled.
4. SAS Library

SAS Library can be seen as the folder that contains all of the SAS files and data sets. There are two types of libraries: Work vs. Permanent.
5. My Folders

The My Folders allows you to quickly access your saved SAS programs.
6. Compile Button

The compile button allows you to compile and execute your SAS programming code.
Programming tip: F3 is the shortcut key to compile the program.
Resources to learn more about SAS interface:
Step 3: Learn SAS Library and Data Sets
SAS Library can be seen as the folder that contains all the SAS files. You can find the Library in the lower left-hand corner of the SAS Studio interface:

Expand My Libraries and you will see 4 built-in libraries there:

If you expand the SASHELP library, you will see many built-in SAS data sets:

Now, double click on the AIR data set to open it.

You will see a data set with two columns: DATE and AIR

These are the SAS variables in the data set.
You will also see the number of rows and columns in the data set above the variables:

SAS Studio displays only 100 rows at a time. You can click the arrow on the top right corner of the data set to move to the next set of observations.

In the bottom left corner, you will also see a list of variable properties.

Above is the data portion of the data set, which shows the data stored in this data file.
You can also see the descriptor portion of the data set:

The descriptor portion of the data set shows the details of the data set such as the number of observations and list of variables. You can see it by running a CONTENTS procedure such as below:
Proc Contents Data=sashelp.air;
Run;
Resources to learn more about SAS library and data sets:
You can also learn more about library creation, saving and loading SAS data sets from our interactive SAS training here.
Do you have a hard time learning SAS?
Take our Practical SAS Training Course for Absolute Beginners and learn how to write your first SAS program!
Step 4: Learn How to Create a Data Set
SAS data set is the file that contains all of the data. It is essential for you to understand how to create data sets.
Data set can be created using a set of code called Data Step:
Code:
Data Test;
A = 1;
Run;
Data set:

You can also create multiple variables and observations using the INPUT and DATALINES statements.
Code:
Data Test;
Input Name $ Age Gender $;
Datalines;
John 28 M
Mary 22 F
Susan 34 F
;
Run;
Data set:

You can also copy and subset a data set:
Code:
Data Test2;
Set Test;
Where age > 25;
Run;
Data set:

There are many ways to create, modify and update data sets in SAS. Below are the resources where you can learn more about data sets:
Our SASCrunch interactive SAS training also includes a 14-page tutorial with exercises and projects on how to create SAS data sets. Check it out here.
Step 5: Learn SAS Functions
Now that you have a solid foundation of SAS data sets, it’s time to start learning how to manipulate data.
One way to manipulate data is to use the built-in SAS functions.
Example 1: SUM Function
Code:
Data Shoes;
Set sashelp.shoes;
Total = Sum(sales, inventory);
Run;
Data set:

The SUM function adds up numeric values.
Code:
Data holiday;
set sashelp.holiday;
Code = substr(category, 4, 2);
Run;
Data set:

Code:
Data Shoes;
Set sashelp.shoes;
UpProduct = upcase(product);
Run;
Data set:

Resources to learn more about SAS functions:
- SAS Video Tutorial
- SAS Function List
- SAS Functions
- SAS Functions Tutorial
- Introduction to SAS Functions
You won’t learn until you start practicing SAS. Want more exercises and projects on SAS functions? Get 30+ SAS function exercises and coding project from our SASCrunch Interactive SAS Training.
Step 6: Learn SAS Variables
In SAS, there are 6 attributes that define each of the SAS variables:
- Name
- Label
- Length
- Type
- Format
- Informat
To view the variable attributes, simply click the variable on the variable list on the left of the data set. The variable attributes will be displayed below the variable list.

Variable Attribute #1: Variable Name
Variable name is used to reference the variable in your program. It cannot be more than 32 characters and it cannot contain any special symbol such as $ or #.

Variable Attribute #2: Variable Label
Variable label is the description of the variable. You can add up to 256 characters to the variable label.

Variable Attribute #3: Variable Length
Variable length is the number of bytes assigned to the variable. Character variable with insufficient length will get truncated.

Variable Attribute #4: Variable Type
In SAS, there are only two types of variables: numeric or character. Numeric variables store numeric values such as age, amount, date and time. Character variables store character values such as comments and descriptions.

Variable Attribute #5: Variable Format
Variable format is used to change the display of the variable values. For example, the numeric value 10000 can be displayed as $10,000 with a proper format.

Variable Attribute #6: Variable Informat
Variable informat is used mostly when importing data or converting variable from character to numeric.

Further resources to learn more about variable attributes:
You can get a complete training on variable attributes from our SASCrunch Interactive SAS Training (module 4).
Step 7: Learn Data Import
Data often comes from an external source. It is essential to learn how to read data from an external file.
To read in an external file such as a text or CSV file, simply use the FILENAME, INFILE and INPUT statements.
Example 1: Importing a space-delimited file
Code
Filename file1 ‘/folders/myfolders/file1.txt’;
Data DS;
Infile file1 firstobs=2;
Input ID $ Age;
Run;
External text file:

Data set:

Example 2: Importing a comma delimited file
Code
Filename file1 ‘/folders/myfolders/file1.txt’;
Data DS;
Infile file1 firstobs=2 dlm=’,’;
Input ID $ Age;
Run;
External text file:

Data set:

Example 3: Importing file where data is aligned by columns
Code
Filename file1 ‘/folders/myfolders/file1.txt’;
Data DS;
Infile file1 firstobs=2;
Input ID $ 1-6 Age 10-11 Gender $ 15;
Run;
External text file:

Data set:

Resources to learn more about data import:
Become a Certified SAS Specialist
Get access to two SAS base certification prep courses and 150+ practice exercises
Step 8: Learn Data Manipulations
In general, 60-80% of SAS programs involve data manipulation. Let’s take a look at some examples of how you can manipulate data in SAS.
Example 1: Sorting Data Set
Code
Proc sort data=sashelp.cars out=cars (keep=make model msrp);
by msrp;
where make = “Acura”;
Run;
Before:

After:

Example 2: Concatenating Data Sets
Code
Data Prdsal;
set sashelp.prdsal2 sashelp.prdsal3;
Run;
Before
SASHelp.PRDSAL2 (23040 observations)

After
PRDSAL (34560 observations)

SASHelp.PRDSAL3 (11520 observations)

Example 3: Flagging Extreme Values
Code
proc sort data=sashelp.class out=class;
by sex height;
run;
data class2;
set class;
by sex height;
if first.sex then flag = “Shortest”;
else if last.sex then flag = “Tallest”;
run;
Before

After

More resources on SAS data manipulations:
Data manipulation is a complex topic. It is much easier to learn this topic using an interactive learning platform where you can practice and work on exercises while you learn.
Try our interactive SAS learning platform free of charge.
Step 9: Learn Data Analysis
SAS is one of the world’s best statistical analysis software. Below are some examples of the data analysis steps that are commonly used.
Example 1: Proc Univariate
Code
Proc univariate data=sashelp.cars;
Var MSRP;
Run;
Proc Univariate is usually used when examining the spread of the data. It displays statistics such as mean, median, mode, quantile and so forth.
Results

Example 2: Proc Means
Code
Proc means data=sashelp.cars;
Var MSRP;
Run;
Proc Means is used to compute summary statistics such as mean and standard deviation. By default, SAS computes N, mean, standard deviation, minimum and maximum of the numeric variables.
Results

Code
Proc Freq data=sashelp.cars;
Table Make * DriveTrain;
Run;
Proc Freq is used to compute frequency statistics. You can use it to create a cross tabulation table across multiple variables.
Results

Further resources to learn more about data analysis:
Data analysis procedures such as proc univariate, proc means, proc freq and proc ttest are also covered in our SASCrunch Interactive SAS training. Start your free training now.
Step 10: Learn Proc SQL
Proc SQL is an advanced programming step commonly used when working with data in relational database. It can often achieve the same results as the traditional data step but with higher efficiency. Let’s take a look at some examples.
Example 1: Retrieving Data from Data Set
Code
Proc sql;
select make, model, msrp
from sashelp.cars
where make = “Audi”
order by msrp;
Quit;
Proc SQL allows you to retrieve data from a data set while subsetting and sorting the data set within the same step.
Results

Example 2: Summarizing Data
Code
Proc sql;
select make,
count(make) as n,
mean(msrp) as mean_msrp
from sashelp.cars
group by make;
Quit;
Proc SQL also allows you to summarize data using the built-in summary functions.
Results

Example 3: Creating Table (Data Set)
Code
Proc sql;
create table bigfish as
select *
from sashelp.fish
where weight >1000;
Quit;
The code above creates a data set BIGFISH that contains only the fishes that are more than 1000 lbs.
Further resources to help you learn Proc SQL:
Results

Step 11: Learn SAS Macro
SAS macro is another advanced programming technique that allows you to perform dynamic value substitution and automate repetitive tasks.
Programming tips: Get yourself familiar with SAS base programming before you start learning complex macro.
Code
%let brand = Audi;
The %let statement creates a macro variable called BRAND. The macro variable is stored in the Global Symbol Table with the text value ‘Audi’.
Results

Code
%let brand = Audi;
proc sql;
select make, model, msrp
from sashelp.cars
where make = “&brand”;
quit;
SAS macro variable can be referenced using the ampersand (&).
Results

Code
%macro pprint (ds);
proc print data=&ds (obs=10);
run;
%mend;
%pprint(sashelp.fish)
SAS macro can be used to automate repetitive tasks.
Further resources to learn more about SAS macros:
Results
