SAS Information

Lee Adkins

1  Getting Started

I assume that you are familiar with the PC, the Windows environment, and Netscape. I assume that you have a formatted diskette in drive A:. Open Netscape and go to my web page at Follow the link for your class and copy the following files to your diskette:

Now open the windows version of SAS, by clicking on its icon. Make sure that the program editor window is active (its title bar will be bright blue) and, using the pulldown menu under File open the program

2  Three SAS Windows

Once the program is open, you will find 3 basic windows: Program Editor, Log, and Output. PROGRAM EDITOR is where you type in your SAS program. From this window you can save your programs into a file, edit a program, submit a program for processing, or print a hard copy of your program. The LOG window contains SAS messages about how your SAS job is proceeding. It contains error messages, success messages, and documents each procedure SAS runs for you. To diagnose problems with your programs, the LOG window is the place to look. The OUTPUT window is where SAS prints out results to your computer screen. You may save these results to a file or print them out.

3  Basic SAS Program

To begin, type in the following program
******************* The DATA Step *********************;
DATA ONE;                          * creates a data set ONE ;
INFILE 'A:\one.dat' firstobs=2;    * reads one.dat, skip line 1;
input yr hw pgnp n pop ql rgnp u r;* INPUT variable names ;
   lnpgnp=log(pgnp);               * take the natural logarithm ;

******************* Procedures ************************;
PROC means data=one;          * call procedure MEANS use data ONE;
run;                          * RUN the program;

The first part of a SAS program is the DATA step; In the program above, the data step consists of the first 4 lines of the program. The statement DATA one; creates a SAS dataset that you are calling ONE that contains the variables named in the input statement. It contains 9 variables that are being read from the file named a:one.dat. The firstobs=2 statement tells SAS to begin reading the file on the second line of the data file. I did this because the first line of the file contains the names of the variables. Following the input statement, you can make any variable transformations you need.

Some of the available functions include:


     ABS(x)          absolute value
     CEIL(x)         greatest integer
     CINV(p,df)      percentile (p) of Chi-square distribution
                     with df degrees of freedom
     EXP(x)          raises e to power
     FINV(p,df1,df2) percentile (p) of F-distribution with
                     df1 and df2 degrees of freedom
     LAGn(x)         n'th lag of variable
     LOG(x)          natural logarithm
     MAX(arg,arg..)  maximum value
     MIN(arg,arg..)  minimum value
     NORMAL(seed)    standard normal random number
     PROBCHI(x,df)   CDF of Chi-square random variable
                     with df degrees of freedom
     PROBIT(x)       inverse function of N(0,1) CDF
     PROBNORM(x)     CDF of N(0,1) random variable
     PROBT(x,df)     CDF of t-distribution with df degrees
                     of freedom
     RANNOR(seed)    standard normal random number
     RANUNI(seed)    uniform random number in [0,1] interval
     SQRT(x)         square root
     TINV(p,df)      percentile (p) of t-distribution
                     with df degrees of freedom
     UNIFORM(seed)   uniform random number in [0,1] interval

After the data step, you are ready to begin processing the data. The program above asks SAS to run the MEANS procedure. After listing any procedures you want to run, your SAS program should be closed using the `run' statement.

To run the program, click on the running man icon while the program editor window is active, or click on local then submit from the menu.

For a summary of SAS commands we will be using (and a few extra) see the summary.doc file available from the web site.

File translated from TEX by TTH, version 1.58.