A Step by Step Guide to Learning SAS. The Fundamentals of SAS Programming and an Introduction to Simple Linear Regression Models September 29 th , 2003 Anjali Mazumder. Objective. Familiarize yourselves with the SAS programming environment and language.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
The Fundamentals of SAS Programming
and an Introduction to
Simple Linear Regression Models
September 29th, 2003
1.1 Windows or Batch Mode?
1.1.1 Pros and Cons
1.1.3 Batch Mode
A bunch of windows will appear – don’t get scared!
sas foo or sas foo.sas
Either way, SAS will create files with the same name as your program with respective extensions for a log and output file (if there were no fatal errors).
You may want more information about a command or some other aspect of SAS then what you remember from today or that is in this guide.
1. Click on the Help button in task bar.
2. Use the menu command – Online documentation
2.1 SAS Program Editor: Enhanced Editor
2.2 Important SAS Windows: Log and Output Windows
2.3 Other SAS Windows: Explorer and Results Windows
This is where you write your SAS programs. It will contain all the commands to run your program correctly.
All the essentials to SAS programming such as the information on your data and the required steps to conduct your analysis as well as any comments or titles should be written in this window (for a single problem). See Section 3-6.
In your home directory. SAS will read and save files directly from there.
Check the Log window every time you run a program to check that your program ran correctly – at least syntactically. It will indicate errors and also provide you with the run time.
There is an output window which uses the extension .lst to save the file.
If something went seriously wrong – evidence will appear in either or both of these windows.
3.1.1 A program!
3.1.2 End of a command line/statement
3.1.3 Run Statement
3.2 Extra Essentials
3.2.4 Case (in)sensitivity
3.1.2 End of a command line or statement
3.1.3 Run command or keyword
/* My SAS commands go here. */
Title ‘Regression Analysis of Crime Data’;
Title1 ‘This is the first title’;
Title2 ‘This is the second title’;
options nodate nonumber ls=78 ps=60
3.2.4 Case (in)sensitivity
4.2.1 Input statement
4.2.2 Datalines statement (internal raw data)
4.2.3 Raw Data Files
4.5.1 View the data set
proc print data=meat;
4.5.2 Create a new from an old data set
4.5.3 Merge two data sets together
5.1 What is proc reg?
5.2 What are the important ingredients?
5.3 What does it do?
5.4 What else can you do with it?
5.5 The cigarette example
5.6 The Output – regression analysis
It is a procedure used to do something to the data – sort it, analyze it, print it, or plot it.
It is a procedure used to conduct regression analyses. It uses a model statement to define the theoretical model for the relationship between the independent and dependent variables.
5.2.1 General Form
proc reg data=somedata <options>;
model dependent=independent <options>;
plot yvar*xvar <options>;
5.2.2 What you need and don’t need?
p prints observed, predicted and residual values
r prints everything above plus standard errors of the predicted and residuals, studentized residuals and Cook’s D-statistic.
clm prints 95% confidence intervals for mean of each obs
cli prints 95% prediction intervals
proc gplot data=somedata;
yvar*xvar=‘char’ obs. plotted using character specified
yvar*(xvar1 xavr2) two plots appear on separate pages
yvar*(xvar1 xavr2)=‘char1’ two plots appear on separate pages
yvar*(xvar1 xavr2)=‘char2’ two plots appear on the sample plot distinguished by the character specification
Now let’s answer the following questions in order to understand all the output displayed.
You should be able to do the:
- manipulate a data set (in various ways)
- use external raw data files
- find the estimated regression line
- plot the estimated regression line with data
- generate confidence intervals and prediction intervals
1. Delwiche, Lora D. (1996). The Little SAS Book: a primer. (2nd ed.)