SAS -- THE SAS LANGUAGE AND SAMPLE PROGRAMS The SAS (Statistical Analysis System) is a software package for data manipulation and statistical analysis. The user writes a SAS program to perform the desired tasks. A SAS program is composed of 2 fundamental components: DATA step(s) -- the part of the program in which a structure for the data to be analyzed is created. This structure exists while the program is running. Variables corresponding to the various elements of the data set are defined, and the data are assigned to the variables. Data may be input manually in the body of the program, or they may be read in from a file. We will not get very fancy in this course with data input and manipulation, but be aware that it is possible to perform very complex data manipulation and to analyze very large data sets using SAS. It is also possible to create permanent data sets and files for use with later SAS runs. PROCs (PROCedures) -- the SAS language is organized into a series of procedures, or PROCs, each of which is dedicated to a particular form of data manipulation or statistical analysis to be performed on data sets created in the DATA step. In the example programs below, we will consider several different PROCS: PROC MEANS: computes means, standard deviations and other summary statistics for some or all of the variables in a data set. PROC TTEST: computes the 2-sample t-test for comparing the means of 2 treatments. PROC REG: performs regression analysis using the method of least squares. PROC GLM: constructs the analysis of variance desired by the user, with associated F statistics, constrasts, etc. PROC PLOT: constructs plots of the data as specified by the user. PROC PRINT: prints the contents of a data set. There are many other PROCs to perform data and other kinds of analyses; The SAS documentation describes these. We will discuss features of the PROCs above and some additional PROCs in lecture, demonstration labs, and in homework assignments. A SAS program consists of one or more DATA steps to get the data into a format that SAS can understand and one or more calls to PROCs to perform various analyses on the data. Several example SAS programs using each of these PROCs are available. The programs are meant to illustrate the features of data input using the DATA step that will be useful to us in the course as well as the syntax used in SAS PROCs. The programs are discussed below and can be viewed and run on SICL. They all reside in the directory /pub/st512/md The example programs are mneumonically named: rcbd.sas: analysis of variance of a randomized complete block design using PROC GLM reg.sas: simple linear regression analysis using PROC REG and PROC PLOT means.sas: summary statistics using PROC MEANS ttest.sas: 2 sample t-test using PROC TTEST paired.sas: paired comparison t-test using PROC MEANS The programs are annotated using comment statements (see below) with descriptions of the functions being executed by each line. The first two programs are discussed in detail below. To view each program, get into SAS and use the SAS command include '/pub/st512/md/nameofile' on the command line of the PROGRAM window. Here, nameoffile refers to one of the 5 names above. The program will appear in the window. You may scroll through the program on the screen or print a hard copy to look at according to the instructions in the manual. You may then submit (execute) the program and view the results in the OUTPUT window. A hard copy of the results may also be printed out or written to a file as described in the manual. You may also get a hard copy of the program. If you wish to practice editing, you may copy the program file to a file in your own directory by using the command file 'nameyouchoose' on the command line of the PROGRAM window. For example, you may wish to save 'means.sas' to your own directory under the name 'mymeans.sas.' To do so, simply type file 'mymeans.sas' No directory information is needed if the file is to be in your own directory; it will automatically be placed there. When the include command is used later to retrieve it, no directory information is required. This will save a copy of the file to the name you choose. Then, clear the window and include the renamed file in the PROGRAM window so that you will be working with it rather than the original. Now, you may practice editing and may augment the program if you wish.