3. Getting Started
You can access the SAS system by logging in to the Open VMS/Alpha cluster, AXP.APPSTATE.EDU, using QVT/Term. There are several methods for running SAS programs, but this document will describe only the noninteractive mode and the batch mode.
SAS Noninteractive Mode
With noninteractive mode your SAS program statements are in a file, and you specify that you want the SAS system to execute the statements in that file by typing the command “SAS filename.sas” at the $ prompt. SAS immediately starts processing the file and ties up your computer until it is finished. Use the VMS editor to create the file containing your SAS program statements, and save the file using the file name extension, .SAS . For example, your SAS program file might be named JOB1.SAS and contain the following statements:
/* JOB1.SAS
Example program to compute frequency distributions on the
responses in a survey data set.
Aug. 10, 2006 */
filenme indata 'survey.dat';
data survey;
infile indata;
input id 1-3 age 5-6 educ 8-9 @11 (q1- q10) (1.) ;
run;
proc freq data=survey;
tables q1-q10;
run;
The data for this program is in a separate file, named 'survey.dat'.
To execute the program, enter the following command at the $ prompt: SAS JOB1
In this command, the word SAS invokes the SAS system, and JOB1 is the SAS program file that you want to execute. You do not need to include the file type (.SAS) in the file name because SAS assumes the .SAS file extension by default. SAS executes the statements in JOB1.SAS and creates two files in the default directory, JOB1.LOG and JOB1.LIS. The file, JOB1.LOG, contains SAS log output, notes relative to processing the data, and any warning or error messages. The second file, JOB1.LIS, contains the results, ie. the output from the SAS Freq procedure. Always be sure to check the log file first for any warning or error messages before assuming the results in the output file are complete and accurate. Sometimes there will not be a __.LIS file produced due to processing errors that occur before any procedure output is generated, and other times the output is incomplete due to warnings or errors that have occurred.
Both the ___.LOG and the ___.LIS file can be viewed at your computer or printed. Use the DCL commands TYPE or EDIT to display the files on your computer.
$ TYPE/P JOB1.LOG or $ TYPE/P JOB1.LIS
$ ED JOB1.LOG or $ ED JOB1.LIS
The command TYPE/P will list the specified file on your computer, one page at a time. The ED command loads the specified file into the VMS text editor where you can scroll forward and backwards through the file. Be sure to leave the editor with the QUIT command rather than with EXIT, so as not to create an extra copy of the ___.LOG or ___.LIS file.
To print the __.LOG or __.LIS file type one of the following commands at the $ prompt.
$ PRINT JOB1.LIS/QUE=COB/note="Your Name"
$ PRINT JOB1.LOG/QUE=COB/note="Your Name"
The PRINT command will produce a paper printout of the specified file using the Pharos print system. It will be printed on a printer in Raley Hall, computer lab 2012 (enter through lab 2010). Ask the lab operators in the student computer lab for help in retrieving your printout.
SAS Batch Mode
SAS batch mode uses the Open VMS batch processing system, and is useful for SAS programs that require large amounts of processing time. In batch mode you submit a job to an Open VMS batch queue and it runs unattended, freeing your system for other work. Although your system is free for other tasks, the batch job itself runs at a lower priority than jobs executed directly from the $ prompt, and therefore batch processing is not recommended for routine work.
To use batch mode, you need to create two files, a command procedure file and a SAS program file. The SAS program file given above, JOB1.SAS, could also be used in batch processing mode. Save the program file as type .SAS, just as you would in noninteractive execution mode. Next, create a command procedure file, which will set up the SAS environment and invoke the SAS system. Use a filename extension of .COM for this file, and give it a name such as RUNSAS.COM. If you are working from the root (home) directory, RUNSAS.COM needs to contain only one line. It should not contain any blank lines. It's only command should be:
$ SAS JOB1
To execute the job, enter the following command at the $ prompt: SUBMIT RUNSAS.COM
After execution, the following files will be created:
JOB1.LOG the SAS log file
JOB1.LIS the output, if there were no execution errors
RUNSAS.LOG the VMS batch system log file, which is automatically created, printed and deleted.
On the SUBMIT command you may use options such as /NOTIFY, /NOPRINTER or /NOLOG
/NOTIFY sends you a beep when execution is complete
/NOPRINTER suppresses printing of the system LOG file
/NOLOG suppresses creation of the system LOG file (Note: this does not
affect the SAS log file, which will still be created.)
For example, enter the following command at the $ prompt:
SUBMIT/NOTIFY/NOPRINTER RUNSAS.COM
If you are working in a subdirectory, then it will be necessary to include another command in RUNSAS.COM. Suppose your SAS command file, JOB1.SAS, is in the subdirectory [.SAS] under the SMITHAA root directory. Then RUNSAS.COM file must contain these two lines:
$ SET DEFAULT DISK$FACST:[SMITHAA.SAS]
$ SAS JOB1
Note that if you are using a data set, such as SURVEY.DAT, then it must also be in the directory [SMITHAA.SAS], or you must fully specify its location in the INFILE or FILENAME command within your SAS file, JOB1.SAS.
The additional command, SET DEFAULT, is required for the VMS operating system to find the SAS program file, JOB1.SAS. The SAS log and output files will be placed in this subdirectory, [SMITHAA.SAS], however, the system log file will still be placed in the root directory, DISK$FACST:[SMITHAA]. If you are not certain of the current active directory, then enter the following command at the $ prompt: SHOW DEFAULT. The command HOME will return you to the root directory, [SMITHAA] in this example.
If you want the system log file to be placed in the [SMITHAA.SAS] subdirectory, then use the following form of the SUBMIT command:
$SUBMIT/LOG_FILE=DISK$FACST:[SMITHAA.SAS]RUNSAS.LOG RUNSAS.COM
Interrupting A SAS Session
When
running SAS in noninteractive mode, you can interrupt the program by
pressing CTRL-Y or CTRL-C. The SAS system will respond with:
Press
Y to cancel submitted statements,
N to continue.
CLEANUP Command
When the SAS system processes data it creates a subdirectory, under the program's default directory, for all its temporary work files. The subdirectory's name is of the form:
SAS$WORKnnnnnnnn.DIR
where the "nnnnnnnn" is the PID, process identification number, of the user's process. These work files and the subdirectory are deleted upon normal completion of the program, but they are not deleted if the program terminates abnormally. Since these files can sometimes be quite large, it is important for you to delete them if your SAS program terminates abnormally. To delete them, simply type CLEANUPat the $ prompt, and respond "yes" to the question:
OK TO DELETE device:[current-dir]SAS$WORKnnnnnnnn.DIR;1[YES]?