Statistical
Software > SAS/WIN Web > Running a
SAS Program
SAS Online Tutorial
III. Running a SAS program
Getting your program into
the Editor Window
The first thing you need to
do is get your program (we will learn all about a SAS program in section
IV) into the Editor Window. You can either type or copy/paste the program
lines below into the Editor Window:
data exercise;
input name $ height weight jog $ tennis $;
datalines;
Robert 68 150 yes yes
George 67 180 no no
Agatha 63 110 no no
Sandy 60 125 yes yes
Bill 65 160 yes no
proc print data=exercise;run;
After you type or copy/paste the program lines, the Editor Window should
look as follows:
Submitting your program
You can run the program by
clicking the running person in the toolbar just under the menu line or
selecting Submit from the Run menu. If you have a divided screen, you
will have to move your tool bar to the left to see the running person.
See the toolbar section under SAS Windowing Environment on how to do this.
Viewing the SAS Log and Output Windows
After you run a program, the
Log Window shows your program along with messages (NOTEs) about the running
of your program. The Output Window displays the output of SAS procedures
(in this case, the output of the PROC PRINT).

Let's take a better look at the Log Window. Click on the maximize
button (middle button, indicated by the arrow below) to zoom the window
and make it bigger.
Now we can see the Log Window better. The log tells us that work.exercise
has 5 observations and 5 variables (that is right) and it tells us that
the PROC PRINT took 0.00 seconds.
Return the Log Window to its original size by clicking the restore
button (middle button). Type or copy/paste the following additional SAS statements to the end of the Editor
Window:
proc means data=exercise;
var height weight;
run;
This is shown below:
Select the new statements to submit, then click on the
running person in the tool bar or select Submit - Run from the menu. This submits the selected statements.
The program is listed in the Log Window and new output appears in the
Output Window.

Results Window
Now that we have run two procedures,
we will explore the uses of the Results window. Click on the Results button
in the SAS task bar and you should see the following Results window:
There is one entry in the window for each procedure we have run. Note
the plus sign (+) to the left of each procedure. If you expand the procedures
by clicking on all the plus signs, you will get the following output:

Using the Results window it is now possible to print or save the
parts of the output you want. Select the item you want in the
Results window and click on the right mouse button. Then select either
Print or Save As from the pop-up menu. You can also print the selected output from the FILE
pull-down menu. To print the entire
contents of the Output window refer to next section "Print Output
Window".
Print Output Window
If you want to print the entire
contents of the Output Window, first activate the Output Window by clicking
in it, then select Print from the FILE pull-down menu. When the Print
dialog box appears click OK.
What happens when you make an error
What happens when you make
an error? Type or copy/paste the program below to the Editor Widow and
run it.
proc means data=exercise;
var height weight z;
run;
The result is shown below. In the Log Window you can see the error message
in red, saying Variable Z not found.
When this happens, you can click the Editor Window, correct the program
(i.e. remove the variable z), select the programming statements you
wish to submit and rerun the selected statements by clicking on the running figure or choosing Submit - Run..
Home | Back | Next
|