one.dat readme.doc prog1.sas
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 prog1.sas.
******************* 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:
Functions
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.