After you follow the above procedure, the SAS windows will appear on the screen. There are three windows, you will probably want to move them around (see below) so that you can see all three simultaneously. The three windows are the program editor, the log window and the output window. The window names will appear in the title boxes of the corresponding windows.
PROGRAM EDITOR window: When you start SAS, the cursor will be on the command line of the PROGRAM EDITOR. This is where you will enter your programs and submit them for execution (i.e., to run). In a moment we will discuss how to type in and edit a program in this window.
LOG window: The LOG window will contain a copy of your program when it is through running, annotated with comments from the system and error messages, if any.
OUTPUT window: The OUTPUT window will contain any output generated by your program.
Moving among windows : Note that each window has a command line. You may switch back and forth from the command line to pull down menus by holding the control key down and pressing a. (This key sequence is denoted by Control-a.) You may move the windows by sliding the mouse over the mouse pad until the on-screen cursor is on the titlebar of the window you want to move and then while holding down the first button slide the mouse again. The cursor should drag a ghost outline of the window until you stop. Release the mouse button when the ghost is positioned where you want the window to be.
In SAS you will have move back and forth between the windows. To do this you just slide the mouse until the on-screen cursor is inside the window you want to use and click the mouse button. The frame of the window should darken letting you know that it is the "current" window.
Editing a program: To type in a program, go to the PROGRAM EDITOR window. In this window, you will type the statements that make up your SAS program.
To begin typing, simply use the arrow keys or the mouse to move down to the first line of the window and start typing the statments. RETURN will take you to the next line. You can move around freely in the window with either the arrow keys or the mouse. If you make a mistake, you can simply backspace over it as if you were using a word processing program.
There is an insert mode and a typeover mode -- in the first, you can insert text in front of other text on a given line by simply moving the cursor (with the arrow keys) to the spot you want to insert and type. In the second, you type over things that are already there. When you start SAS, you are in typeover mode. To get into insert mode, type the key sequence Control-x (or Control-n for remote access). To get delete mode back, press that same key sequence again. Notice that the cursor changes shape depending on which mode is being used. It is a block cursor in typeover mode and an underline cursor in insert mode. Try using both modes so that you understand the difference.
Saving a program file: Once you have typed in your program and have it
the way you want it, you will want to save it in a file so that you
can access it again. In particular, you may run the program and find
it has errors, but you need to go to class and wish to come back later
to work on it some more. To save a program in a file, type the
following command at the command line of the PROGRAM EDITOR window:
file 'filename'
and hit RETURN. Here, filename is the name you have chosen for the
file. The name must be in single quotes as above. Notice the single
quotes -- you must enclose the name in them. If you are using
pulldown menus, go to the "file" menu and select "Save as -> Write to
file" . You will then be prompted for a filename. The file is now
saved under this name in your directory.
You can also save the contents of the LOG and OUTPUT windows to files if you desire with the same command in the same way.
Including a file: While we're on the subject, suppose you come back
from your class, login, enter SAS, and wish to work on the program
some more. To get the contents of the file back into the PROGRAM
EDITOR window, type at the command line of the PROGRAM EDITOR window:
include 'filename'
and hit return. Here, filename is the name of the file whose contents
you wish to appear in the window. Again, the name must be enclosed
insingle quotes. If you are using pulldown menus select "Open -> Read
file" in the "File" menu. In fact, even if the window already
contains some program statements, including a file will cause the
statements in that file to be added to the end of those already there.
This is useful if you want to combine 2 programs into 1.
The include command is only valid in the PROGRAM EDITOR window.
Running a program:
Suppose you have entered a program and wish to run
it, that is, submit it to SAS to obtain the analysis you desire. Go
to the command line (use arrow keys, the mouse, or the keystroke
sequence Control-f). Type submit OR use Control-E. If you are using
pulldown menus select "Submit" from the "Locals" menu. The program
will disappear from the window, as will the cursor. Note that if use
"submit" (either by typing it on the command line or by using pulldown
menus) rather than control-e you must"clear" both the output window and
the log window before submitting another program (see below for more
details).
Examining the results of running a program:
The clear command:
Whether or not you print the contents of a window,
you should type clear at the command line (or choose "Clear text" from
the "Edit" menu if using pulldown menus) when you are finished viewing
its contents on the screen. If you do not, and you run subsequent
programs, the logs for all of them will continue to "pile up" in the
LOG window, and their output will "pile up" in the OUTPUT window,
making it difficult to determine which is the relevant part you wish
to look at in each case. Further, if you print the contents of the
window, everything will be printed, wasting paper and tying up the
printer. The clear command deletes everything from a window. It is
thus a good idea to remember to clear anything with which you are
finished as you work.
Printing the contents of a window:
On the command line of the window you want to be printed, type the
command "print".
If you are using menus you can also choose "print" from the file
menu.
This prints the entire contents of the window, not just the part of
the window you see on the screen.
Exiting SAS:
You may exit SAS from any window by simply typing from
any command line
bye
and then hitting RETURN or by choosing "Exit" from the "File" pulldown
window. This will return you to the % prompt (at which point you may
logout, if desired).