INTRODUCTION TO SAS FOR WINDOWS ON THE NOVELL NETWORK
AT THE UNIVERSITY OF IDAHO
SAS is a software system for data analysis. This is an introductory guide for people who have not used SAS for windows before. Basic SAS software provides tools for information storage and retrieval, data modification and programming, report writing, statistical analysis, and file handling.
I. Requirements for SAS for Windows at the University of Idaho
The SAS system resides on the Novell network at the University of Idaho. You must have access to the system or have SAS for Windows installed on a personal computer. You may also want to carry a disk to the computer with a previously saved data set. A disk is also useful to save data and output files.
II. Getting Started
After Login:
Double click on "Labsoftware"
Double click on "Math & Statistics"
Double click on "SAS 6.12"
Double click on "The SAS system for windows v 6.11"
You will see a warning which says:
Notice: Due to problems in version 6.12 of SAS, it has been replaced with version 6.11.
Click on OK. The SAS program is now running.
You are now in SAS for Windows. There is a menu bar at the top of the screen which shows:
FILE EDIT VIEW LOCALS GLOBALS OPTIONS WINDOWS HELP
This menu bar helps you manage your program. Some examples of things you can do are open, save, print a SAS file, choose from different SAS subwindows, or get help.
There are three primary windows in SAS. The 'Program Editor' window is used to enter, edit, and submit SAS programs. The 'Log' window displays messages about the programs you submit. The 'Output' window displays output from procedures.
Only one window at a time is active. The active window is where your cursor is located. Commands you give through the SAS menu bar will be executed in the active window. You can scroll through windows using the arrow buttons, and can enlarge a window by clicking on the up arrow in the right hand corner of the window. To change windows use the mouse to select a window, or choose 'Windows' from the menu bar at the top of the screen.
III. Using the SAS System For Data Analysis
A SAS program consists of a series of statements. Each statement must end with a semicolon. The two main steps in preparing a SAS program are the DATA step which creates a SAS data set, and the PROCEDURE step which performs tasks on the data. To enter your SAS program make sure your cursor is in the 'Program Editor' window, and then you may begin typing.
Here are two examples of a SAS program. The first program includes the data in the SAS program using a cards statement. The second uses the same data but reads it from a data set previously saved on a disk.
| Include the data set in the SAS Program | Read the data from an ASCII file |
| data one; | data one; |
| input eyea $ sysal sysa2 sysa3 fngr ht ; | infile 'a:bp.txt'; |
| input eyea $ sysal sysa2 sysa3 fngr ht ; | |
| sysmn = mean(sysal,sysa2,sysa3); | sysmn = mean(sysal,sysa2,sysa3); |
| label sysmn ='Systolic BP'; | label sysmn ='Systolic BP'; |
| label ht ='Height'; | label ht ='Height'; |
| label fngr =Finger Length; | label fngr =Finger Length; |
| title Distribution of student data; | title Distribution of student data; |
| cards; | |
| g 121 124 128 4.1 72 | |
| bl 113 125 110 3.5 62 | proc print; |
| br 129 122 120 3.2 74 | proc means; |
| br 129 136 130 3.5 72 | var sysmn ht ; |
| n 116 164 132 3 63 | proc plot ; |
| br 138 121 123 3.2 72 | plot sysmn*fngr ; |
| bl 122 130 126 3.6 72 | proc univariate plot normal ; |
| n 120 121 110 3 71 | var sysmn ; |
| ; | run ; |
| proc print; | |
| proc means; | |
| var sysmn fngr ht; | |
| proc plot; | |
| plot sysmn*fngr; | |
| proc univariate plot normal; | |
| var sysmn ; | |
| run ; |
The Data Step
The first part of the SAS program is the data step. The data step names the SAS data set, identifies the location of the data, describes the data values to be read, and computes new variables.
The DATA steps in the above example included:
1. DATA statement The general form is: DATA name;
This is the first statement in your SAS job, marks the beginning of the Data Step, and gives the name you choose for the SAS data set you are creating. The data set name must begin with a character or an underscore, can include characters, underscores, or letters, and is limited to eight characters.
2. The INFILE or CARDS statement identifies the location of the data. The general form of an INFILE statement is: INFILE 'filename' ; . If you are including the data in the SAS program, put your data lines immediately after the CARDS statement, then have a semicolon placed after the final data line.
3. INPUT statement The INPUT statement describes the data to the SAS system and assigns variable names. Each variable must be defined as either character or numeric. A $ sign after the variable indicates a character variable. For example eyea $ is a character variable.
4. Creating new variables To create a new variable, you must specify the new variable name and the expression for calculating it. The assignment statement in the previous program is: sysmn = mean(sysal,sysa2,sysa3); .
The Procedure Step
The second part of a SAS program is the procedure step. SAS procedures are computer programs that use your data set to perform various computations, and print results.
The general form of a SAS procedure is:
PROC NAME DATA=NAME;
... other lines specific to the procedure NAME ...
RUN;
If a SAS data set name is not specified, SAS uses the most recently created data set. The procedure steps in the program above included:
1. PROC PRINT Asks SAS to read a data set, arrange all the variables in an easy to read form, and print them. To select specific variables to be printed, add a VAR statement followed by the variable names. For example to only print eye color and height we could modify proc print to: proc print ; var eyea ht ;
2. PROC MEANS This statement asked SAS to generates simple descriptive statistics on the variables sysmna, fngra, and hta. If the VAR statement would have been excluded SAS would have computed descriptive statistics on all of the numeric variables. The default statistics are min, max, average, and standard deviation. After the PROC MEANS statement you can specify which statistics you want computed. For example if you just want a minimum value and the sum of each variable computed, then the first line of the procedure would look like: proc means min sum ; .
3. PROC CORR Asks SAS to compute correlation coefficients (Pearson by default) among the variables listed.
4. PROC PLOT Asks SAS to create a plot of the data. For example plot sysmn*fngr ; gives SAS the details of the plot. The variable sysmn will be used on the vertical axis, and fngr will be used on the horizontal axis.
5. PROC UNIVARIATE Asks SAS to run descriptive statistics with options to plot the listed variables, and test the normality of the variables.
6. RUN Instructs SAS to run the previously listed data step or procedure. End your programs with a run statement to ensure that SAS will run all procedures that you have requested.
IV. Subwitting or Running a SAS Program
To submit a SAS program make sure that your cursor is in the 'Program Editor' window and press <F8> or click on the person running icon to submit a SAS program. Or through the menu bar at the top of the screen choose 'Locals', 'Submit'. Your program will disappear and the 'Log' window will start showing your SAS statements and notes with information about the programs progress. The output window will come up automatically when the program is finished, and will have the results of your procedures. You can print or scroll through any of the windows that you wish. If something is wrong with your SAS program, SAS will give red error messages in the LOG file. If you receive red error messages you should go back to the "Program Editor", recall your program by hitting <F4> or choosing "Locals" and "Recall text" from the menu bar, and then correct your codes and rerun the program. Before re-running a program it is often helpful to clear the LOG and OUTPUT windows of their text from the run that generated the error messages. An easy way to do this is to select the window and use <CNTRL>-<E> to clear it.
V. Function Keys
The menu bar at the top of the screen will help you manage your SAS program. SAS has created some function keys for the commonly used commands to help you save time. Some of these keys are <F4> recall the program, <F5> go to the 'Program Editor' window, <F6> 'Log' window, <F7> Output' window, and <F8> submit a program to be run. To get a complete list of function keys choose 'HELP' and then 'KEYS' from the menu bar.
VII. To Save, Retrieve, and Print
Click the following menu commands from the menu bar at top of the screen with the mouse.
To Save: SAS will save the active window that your cursor is in.
1.Click 'FILE'
2. Click 'SAVE AS' if the file is new or you want to rename the file. Otherwise click 'SAVE'.
3. Specify the drive and the name of the file. You can save it on either a floppy disk or a hard drive. If you are working on University Computers it is a good idea to save your work on a floppy disk or to the G drive.
4. Click 'OK'.
To Retrieve a File: If you want to work with a file that has been previously saved make sure the 'Program Editor' window is active.
1.Click 'FILE'
2. Click OPEN
3. Select the drive where your file has been saved, choose the file name, and click on the 'OK' box.
4. If successful you will see the file in the 'Program Editor' window.
Printing: You can print from any window.
1. Make sure the window that you wish to print is active by selecting it with your mouse.
2. Click 'FILE'
3. Click 'PRINT'
4. From the print window, select the proper printer options with your mouse.
5. Click 'OK'
VIII. Exiting The Program
Before exiting, save any files needed for future use.
1. Select 'File' from the menu bar.
2. Select'Exit'
IX. For More Information
Two books for further reading are: SAS user's Guide: Basic and SAS User's Guide: Statistics.
There is a SAS tutorial available on the Novell Network at any of the student labs. To run the tutorial, at the main menu select: 'Tutorials', and then 'SAS Tutorial'. Good luck!
Prepared by: Hongpei Zhang, 12/1994
Revised by: Li Zeng 1/1998
[ SCC Home ] [ U of Idaho Division of Statistics ]