To run SAS in the Assignment Lab you should
turn on the computer if necessary, and let it run through its initial set-up.
Then find STAT in the menu, either by using the down arrow key or the
mouse. Then press the Enter key,
or, if you used the mouse, click the upper left-hand button. Repeat the above
to select the correct course number from the menu that appears next.
You will then be asked to enter your ID. Your Assignment Lab ID is the
first letter of your first name, followed by the first three letters of
your surname. For example, mine is RLOC. Then enter your password.
Yours is the first seven digits of your SFU ID. You should some time
soon, explore the menus to find a way to change your password to something
more secure. Once you are signed on, a menu will appear. (This
takes quite a while --- in the meantime you will see a message about
``preparing Hard Drive for Windows''.) Using the arrow
keys or the mouse, select Windows from the menu. Wait for the
windows display to appear, and use the mouse to move the cursor to the
SAS icon inside the window toward the lower right part of the screen.
Depress the left-hand button on the mouse twice in
fairly rapid succession. This will activate SAS for windows. A small
hour glass will replace the cursor momentarily if you have succeeded.
However, it may revert back to the arrow and appear to be hung up. Be
patient. SAS
is a large program that may take up to several minutes to get running under
heavy simultaneous demand.
If you have a UNIX account with access to Beaufort, you can run SAS
on that machine as well. Experienced SAS users often
find the UNIX environment more convenient.
Once you get SAS running on a PC, you should have a screen with three
coloured windows, called child windows. Two will be plainly visible.
These are the log window in grey at the top, and the
program editor window in blue at the bottom. You may see a
green section between these. This
is the output window, hidden in the background behind the other two.
When you run a successful set of SAS commands, the green output window
will automatically pop to the front.
Practice first moving from window to window. A failsafe way to do this is to
use the mouse to move the cursor to the word, Windows, at the top of the
screen. Then depress the left-hand button on the top of the mouse. This will
make a small menu of windows appear. Move to the one you want, and click the
left-hand button. The selected window should become highlighted. Try it with
all three. Note how the output window completely hides the others with its
large size.
We shall also want to take advantage of some menus for each of the windows.
If they are not already displayed, move the mouse to the word, Options,
at the top of the screen. Then depress the left-hand button on the top of
the mouse. Move the cursor to the item, Preferences in the menu that has
just popped up, and click the left-hand mouse button. Then repeat this process,
``clicking'' on Popup and then Save.
Now activate the program editor window. You can use this window to enter your
program, and can include the
data in the program as well. However, it is typically more convenient to use
a separate data file. We shall first use the program editor window to create and
store such a file.
Use the mouse if required to position the cursor near the upper left-hand corner of
the blue, program editor window, and click the left-hand button.
You should aim for the left-hand end of the second line. If the next
step fails, then move the cursor down slightly.
Enter the following lines of data, moving to the next line down
each time with the enter key. To save space, the data are printed below
in two sets of two columns each. Your screen should contain one set of
two, long columns.
M 13.3 F 30 F 23.2 As one M 21 M 24 set of M 8 F 22 F 12 M 20 t c F 23 M 19 w o F 21.7 F 21 o l M 12 F 26 u M 18 M 31 l m M 22 M 20 o n M 12 F 28 n s M 16 F 16 g
Check your work. Use the ``page-up'' and ``page-down'' keys (or the scroll
bar if you know how to use it) if necessary. (WARNING: if, when you
push page-up or page-down you just get numbers typed check to see if the
green light labelled num lock is on; if so find the key marked num lock
on the number pad and push it once to make that light go off.)
If you find a mistake, use the arrow keys or mouse to move the cursor
to the error, and correct it. You can
use the delete or backspace keys to delete an error, and can enter
an entire new line if you want. Try making a few changes, even if
your data entry has been perfect.
Once you are satisfied with the data, you can file them away.
To do this, click on the right mouse button while the mouse cursor is
located in teh Program Editor window. This will make a menu ``pop up''.
Select (with the left mouse button) File from this menu.
Then select Save as, followed by Write to file. A new
window will appear. Type `` a:raw.dat''. This will tell SAS to use
the file name, raw.dat, on the `a' drive (the one with your floppy disk
in it), to store your data.
You can now type in SAS commands for analyzing the data. (The data are a
shuffled version of the data set on pages 23 and 176 of the SAS System
for Elementary Statistical Analysis, and are measurements of percent body fat for
13 males and 10 females in a fitness center.) We shall ask SAS to sort these
data by sex, and to make some summary statements for each group.
First, you will want to clear the text from the Program Editor window. Make the menu pop up in that window again. Click on the Edit item when the menu pops up, and then click on Clear text. Now, move the cursor to the start of the first line in the Program Editor window, and type lines of code so as to make the following screen display. Note that a SAS line always ends with a semi-colon.
options pagesize=60 linesize=80; data bodyfat; infile 'a:raw.dat'; input sex $ fatpct; proc print; run;
If you did not already erase the numbers from the subsequent lines, you can do so now by typing blanks on top of them, or by marking text by dragging the mouse over segments to be deleted with the left-hand button depressed, and then using the delete key to delete the marked portions. Check your entered lines, and edit where needed. Their purpose is as follows:
Once you are satisfied with the program lines, click on the Locals
menu item on the Program Editor window, and select the item, Submit
to instruct SAS to process these lines. Watch the grey window. It should display
a log of your session, including any possible errors. It may
take a while. Again, be prepared to wait. If you did not
make an error, you should see the green window pop into the foreground. If
not, and the contents of the grey window go by too rapidly, you can move the cursor
to it (by using the mouse or
Windows menu). Then use the page-up key or the scroll bar on the
right-hand border of the window to review the previous components of the log.
(You use the mouse to activate the scroll bar. Experiment with it if you have
never used a scroll bar before, and see if you can get it to work.)
If you made an error, you will have to try again. You can do this by recalling
the previously submitted lines. This in turn is done by activating the
Program Editor window, and clicking on Locals from its header, and
then Recall from the menu that appears. Then try to correct
the error. (This is undoubtedly the most frustrating part of using SAS. If
a more experienced user owes you a favour or two, you might want to call in
some assistance. The SAS manuals are so extensive, that it is hard for
the beginner to know where to look for help. In particular, see the comments
on unbalanced quotes in item 3 above.)
Assuming that you did not make an error, you should see the data printed in the output window. You can now proceed to the sorting and production of summaries. Move the cursor to near the upper left-hand corner of the Program Editor window, and type lines of code to create the following display:
proc sort data=bodyfat; by sex; proc means data=bodyfat; by sex; var fatpct; run;
Check these lines for accuracy and edit where necessary. Their purpose is as follows:
Unless you goofed, the green output window will have again popped to the
foreground. Examine the results. The page-up and page-down keys or scroll bar will help you
move up and down through the display.
Now return to the program editor window, and type in the following lines:
proc chart data=bodyfat; vbar fatpct/group=sex; title 'Crude Side-by-Side Histograms'; run;Then Submit{ them using the Locals menu.
You should by now be able to guess the role of each of the above statements.
See if you can predict the results of changing in the second line, (i) vbar
to hbar, and (ii) deleting the optional portion, /group=sex.
Check your intuition by recalling the former statements to the
programme editor, modifying the second line, and re submitting the lines
to
SAS.
To save the results in a file, use the menu bar on the Output window.
Click on File, Save as, and then Write to file. Then type
the name, a:results. This will save the output in the file named
results on your floppy disk in drive `a'.
You can print a copy of the output using the Print option from the
File menu on the Output window, as long as you have a printing card
for using the local printer. You can also take the diskette with you to
amother DOS machine with a printer, and print it there.
You can,
of course, also file a copy of your commands, edit them elsewhere, and
then, with the Open option in the File menu on the
Program Editor window, incorporate them into a subsequent
analysis. This is one of the major advantages of SAS. It makes it relatively
easy to do repetitive, identical or very similar analyses. A later exercise
will give practice in this skill.
When you are finished running SAS, click on the File menu on either the Program Editor or Log window, and select Exit .... Confirm your choice when asked. Then select the File menu from the Program Editor window, and from it, Exit Windows.... Again, confirm your choice. Finally, use the mouse to move to the LOGOUT section, and click the left-hand mouse button, twice if required, and then confirming this choice if asked.
SAS produces an intimidating set of manuals. You may find the following useful:
Written by C. B. Dean and edited by R. Lockhart on Oct 1, 1995