- SAS - Dates & Times
- SAS - Macros
- SAS - Input Methods
- SAS - Functions
- SAS - Decision Making
- SAS - Loops
- SAS - Operators
- SAS - Numeric Formats
- SAS - Arrays
- SAS - Strings
- SAS - Variables
- SAS - Data Sets
- SAS - Basic Syntax
- SAS - Program Structure
- SAS - User Interface
- SAS - Environment
- SAS - Overview
- SAS - Home
SAS Data Set Operations
- SAS - Simulations
- SAS - Output Delivery System
- SAS - SQL
- SAS - Format Data Sets
- SAS - Sort Data Sets
- SAS - Subsetting Data Sets
- SAS - Merging Data Sets
- SAS - Concatenate Data Sets
- SAS - Write Data Sets
- SAS - Read Raw Data
SAS Data Representation
SAS Basic Statistical Procedure
- SAS - Hypothesis Testing
- SAS - One-Way Anova
- SAS - Repeated Measure Analysis
- SAS - Fishers Exact Tests
- SAS - Chi-Square
- SAS - Bland-Altman Analysis
- SAS - Linear Regression
- SAS - Correlation Analysis
- SAS - T Tests
- SAS - Cross Tabulations
- SAS - Frequency Distributions
- SAS - Standard Deviation
- SAS - Arithmetic Mean
SAS Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
SAS - Program Structure
The SAS Programming involves first creating/reading the data sets into the memory and then doing the analysis on this data. We need to understand the flow in which a program is written to achieve this.
SAS Program Structure
The below diagram shows the steps to be written in the given sequence to create a SAS Program.
Every SAS program must have all these steps to complete reading the input data, analysing the data and giving the output of the analysis. Also the RUN statement at the end of each step is required to complete the execution of that step.
DATA Step
This step involves loading the required data set into SAS memory and identifying the variables (also called columns) of the data set. It also captures the records (also called observations or subjects). The syntax for DATA statement is as below.
Syntax
DATA data_set_name; #Name the data set. INPUT var1,var2,var3; #Define the variables in this data set. NEW_VAR; #Create new variables. LABEL; #Assign labels to variables. DATALINES; #Enter the data. RUN;
Example
The below example shows a simple case of naming the data set, defining the variables, creating new variables and entering the data. Here the string variables have a $ at the end and numeric values are without it.
DATA TEMP; INPUT ID $ NAME $ SALARY DEPARTMENT $; comm = SALARY*0.25; LABEL ID = Employee ID comm = COMMISION ; DATALINES; 1 Rick 623.3 IT 2 Dan 515.2 Operations 3 Michelle 611 IT 4 Ryan 729 HR 5 Gary 843.25 Finance 6 Nina 578 IT 7 Simon 632.8 Operations 8 Guru 722.5 Finance ; RUN;
PROC Step
This step involves invoking a SAS built-in procedure to analyse the data.
Syntax
PROC procedure_name options; #The name of the proc. RUN;
Example
The below example shows using the MEANS procedure to print the mean values of the numeric variables in the data set.
PROC MEANS; RUN;
The OUTPUT Step
The data from the data sets can be displayed with conditional output statements.
Syntax
PROC PRINT DATA = data_set; OPTIONS; RUN;
Example
The below example shows using the where clause in the output to produce only few records from the data set.
PROC PRINT DATA = TEMP; WHERE SALARY > 700; RUN;
The complete SAS Program
Below is the complete code for each of the above steps.