Guide to Using SAS on Alpha/VMS System
Note: Return to reference manual view.
1. Introduction
SAS, Statistical
Analysis System, is a very large, comprehensive software system with
tools for data access, management, analysis and presentation. In
addition to statistical analysis, the system provides software for
decision support, data visualization and information delivery, and
includes the following modules: Base SAS, ACCESS, AF, ASSIST, CONNECT,
EIS, ETS, FSP, GIS, GRAPH, IML, INSIGHT, LAB, OR, QC, SAS/SECURE,
SHARE, SPECTRAVIEW, STAT and TUTOR. This document gives a brief
introduction to using the base SAS system on the Alpha/VMS operating
system. SAS is also available on the Windows operating system, and
introductory documentation can be found at
http://www.its.appstate.edu/stats/stat_doc/SAS9_win.html
For information about the complete SAS system, see their web site: http://www.sas.com/
2. User Guides and Documentation
SAS
documentation is available in three formats: HTML, PDF, and hard copy.
SAS OnlineDoc is a complete reference for the SAS system, covering base
SAS as well as all the SAS modules. It offers a full text search
facility, a comprehensive master index as well as individual book
indexes. It can be accessed by pointing your web browser to:
http://support.sas.com/documentation/onlinedoc/sas9doc.html
For information about the hard copy books available, point your browser to:
http://www.sas.com/apps/pubscat/welcome.jsp
For the new user, the following book provides an easy-to-read introduction to the most commonly used features of SAS software. The book covers getting started with SAS software, getting data into the SAS system, working with the data, and summarizing the data with reports and tables, and some basic statistical procedures.
“The Little SAS Book: A Primer, Third edition” ISBN: 1-59047-333-7 $45.95
All hard copy documentation for the SAS system can be ordered from:
SAS Institute Inc. phone: (800) 727-3228
Cary , NC 27513-2414 fax: (919) 531-9439
or from the web: http://www.sas.com/apps/pubscat/welcome.jsp
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]?4. Data Sets
SAS Data Sets
When a one-word name is used in the DATA statement of a SAS data step, a temporary data set is created, which is available only during the current job. In order to save a permanent SAS data set that will be available for use in future programs, a two-level name containing a libref must be used in the DATA statement.
SAS data sets differ from .DAT external files in the way the data is stored. Descriptive information about the SAS data set is saved automatically with the file. A SAS data set can not be viewed with the VMS editor, but you can use the SAS procedure CONTENTS to print a description of the file's contents.
In order to read or create a permanent SAS data file, the LIBNAME statement must be used. It associates a libref with a SAS data library, that is, with a VMS directory. The general form of the LIBNAME statement is:
LIBNAME libref engine-name 'VMS directory' engine/host options;
Both the engine/host options list and the engine name are optional. The version 9 engine is identified by the term V9 or BASE in the libname statement. The term BASE is a generic term, referring to the default engine in the current version of SAS, and therefore it will refer to the V9 engine if you're running SAS version 9. If the engine name is omitted, the system will assign the engine based on the type of SAS data sets in the referenced subdirectory. If there are both version 9 datasets and data from earlier versions, then SAS assigns the V9 engine. The following LIBNAME statement associates the libref, MYLIB, and the version 9 engine with the directory, DISK$FACST:[SMITHAA]
LIBNAME MYLIB V9 'DISK$FACST:[SMITHAA]' ;
The libref, MYLIB, can be used to create or access version 9 SAS data sets. When creating stored formats with PROC FORMAT, it is recommended that the libref, LIBRARY be used. This libref is required when the formats are used in subsequent programs.
The following example will create a permanent SAS data set named WEATHER.SAS7BDAT in the faculty directory, SMITHAA. Note that the libref (MYDIR) must be 8 characters or fewer, but the data set name (WEATHER) can contain up to 32 characters. Spaces are not allowed in either the libref or data set name.
LIBNAME MYDIR V9 'DISK$FACST:[SMITHAA]';
DATA MYDIR.WEATHER;
INFILE 'SOUTHEASTERN.DAT';
INPUT TEMP 1-5 PRECIP 7-10 SUNHRS 12-15;
RUN;
To read this SAS data set in another SAS job, you need to use a two-level name and the SET command. The new LIBNAME statement must reference the same directory, but the libref name does not have to be the same. The following example reads the file, WEATHER.SAS7BDAT and creates a new SAS data set, RAINYWEATHER.SAS7BDAT, which is a subset of the original:
LIBNAME MYDIR V9 'DISK$FACST:[SMITHAA]';
DATA MYDIR.RAINYWEATHER;
SET MYDIR.WEATHER;
IF PRECIP>0;
RUN;
Converting Version 8 Data Sets and Catalogs to Version 9
SAS version 8 data files (*.sas7bdat file extension) can be read and updated by SAS 9.1.3 directly without doing any conversion. If you simply read your version 8 data set using a SAS 9.1.3 program and save it, it will be saved as a version 9 file.
However version 8 catalog files need to be exported to transport mode using Proc Cport, and then imported into version 9.1.3 using Proc Cimport. You will need to have access to both SAS version 8 and SAS version 9.
Using SAS version 8, run a program similar to the following. This program assumes that the version 8 catalog files are in the subdirectory [SMITHAA.V8CAT], and the transport file will be created in the subdirectory [SMITHAA.V9FL].
/* CPORT_V8.SAS */
LIBNAME SOURCE ‘DISK$FACST:[SMITHAA.V8CAT]';
FILENAME TRANFILE ‘DISK$FACST:[SMITHAA.V9FL]CATLG.XPT';
PROC CPORT
LIBRARY = SOURCE FILE=TRANFILE
MEMTYPE=CATALOG;
RUN;
Switch to SAS version 9.1.3 and run a program similar to the following. The new version 9 catalog file will be created in the subdirectory [SMITHAA.V9FL].
/* CIMPORT_V9.SAS */LIBNAME V9LIB ‘DISK$FACST:[SMITHAA.V9FL]';
FILENAME TRANFILE ‘DISK$FACST:[SMITHAA.V9FL]CATLG.XPT';
PROC CIMPORT
LIBRARY = V9LIB INFILE=TRANFILE;
RUN;
5. SAS Sample Library
There is a SAS sample library available which contains a collection of SAS data sets and sample programs illustrating many different procedures. The programs are grouped into subdirectories according to application, such as base SAS, statistics, and graphs. To see a listing of the subdirectories type:
$DIR SAS$ROOT:[SAMPLES]
and then select the area of interest, such as statistics:
$DIR SAS$ROOT:[SAMPLES.STAT]
You can copy the data sets and programs into your space, edit them and run them. For example:
$COPY SAS$ROOT:[SAMPLES.STAT]TTESTEX.SAS -
__$ DISK$FASCT:[SMITHAA]TTESTEX.SAS
