SAS stands for STATISTICAL ANALYSIS SYSTEM
SAS software (Click here for free SAS software access)
SAS has 3 windows:
- Editor/code window : A place where we write our codes/programs.
- Log window : All the executed SAS codes are printed in this window along with any error or warning messages. A PUT statement can be used to print the output in the log window.
- Output window(non default window) : Appears only where there is an output from the sas program mostly whenever a dataset is created(dataset is a sas file which has data in the form of rows(observations) and columns(variables)).
- Result window : Place where we can see the result from the sas code which is only viewed but is not saved.
Editor/code window
Log window
Output window
How does a SAS data looks like?
A SAS data set contains data values that are organized as a table of observations (rows) and variables (columns) that can be processed by SAS software.
The below image has 4 variables i.e, name, age, height and weight and 3 observations.
SAS Components
- Base SAS – Basic procedures and data management
- SAS/STAT – Statistical analysis
- SAS/GRAPH – Graphics and presentation
- SAS/ETS – Econometrics and Time Series Analysis
- SAS/INSIGHT – Data mining
- Enterprise Miner – data mining
- Enterprise Guide - GUI based code editor & project manager
- SAS EBI - Suite of Business Intelligence Applications
Basic SAS programming guidelines:
- Each statement ends with a semicolon.
- Example: Data sample; Input id;
- A single statement can be written in multiple lines or multiple sas statements can be written in single line.
- SAS statements are not case sensitive.
- Every data step and proc step should end with RUN statement and proc sql should end with QUIT statement
- Example - data step: Data sample;var1=10;run;
- Example - proc step: proc print data=sample;run;
- Example - proc sql;select * from sample;quit;
- All the sas variable names should be between 1 to 32 characters.
- SAS variable names can start with a underscore (_) or character but cannot start with number. Blank spaces and few special characters like $,%, & are not allowed in the variable names.
- SAS code comments are specified in two ways.
- commenting starts with asterisk(*) and ends with semicolon(;) --- * comment ;
- Example:
- * mention the comments;
- * comment line 1
- commenting starts with /* and ends with */ --- /* comment */
- Example:
comment line2
comment line 3 */
SAS Programming:
Every sas code starts with either a DATA step or PROC step
DATA step
- Data step starts with keyword DATA and ends with RUN statement
- One of the way to create a dataset
- Data step is used to get the data from a raw file like excel ,text etc.
- It is used to manage the data, create new variables, transform the data.
- Create variables and observations
Sample code:
Output:
PROC step
- Proc step starts with keyword PROC and end with RUN statement.
- Proc steps are nothing but inbuilt procedures available in SAS.
- These are used to analyze the data, view the data and generate reports.
Sample code:
Output:
No comments:
Post a Comment