SAS for UNIX: Batch Processing

Platform: Unix
Level of Difficulty: Beginner
<hr>
Rutgers Main | OIT Main | NBCS Main | NBCS Documentation Main


Overview

SAS on the RCI system may be run in either of two modes: batch or interactive. In batch (i.e., noninteractive) mode users prepare a file containing SAS statements to be submitted for processing. When processing is complete SAS creates one or more files containing output which may be printed and/or viewed at a terminal. Batch mode processing is useful for large, time consuming, SAS jobs, and for relatively routine SAS jobs which have been tested and shown to be error free. This document describes the use of SAS in batch mode.

Conventions

Within this document, UNIX commands that you will enter at your terminal are in Bold Courier font. Information intended to be typed into files or windows appears in boldface. Filenames and (sub)directory names are in italics.

Sample Run

Step 1:

Use the Emacs text editor to create a file called try1.sas containing the SAS statements and raw data below (enter emacs try1.sas at your terminal).

     data test;
     input id var1 var2;
     cards;
     01 2 3
     02 4 4
     03 4 2
     04 2 1
     05 2 3
     06 3 9
     ;
     proc print data=test;
     run;

Type <Ctrl>x <Ctrl>s to save what you just entered (i.e., hold the <Ctrl> key and press x, then hold the <Ctrl> key and press s). Press <Ctrl>x <Ctrl>c to exit emacs . (See the document entitled GNU EMACS Short Form for more details on using Emacs)

Use the ls command to list the files in your directory. Note that you now have a file called try1.sas.

Step 2:

Enter the following command at your terminal to submit the SAS statements and data contained in try1.sas for processing (do not include the first ">" - that is the terminal prompt).

     > sas609 try1.sas (to invoke SAS Version 6.09)

     > sas611 try1.sas (to invoke SAS Version 6.11)

After the job runs, SAS will create two files. The SAS Log (try1.log) is the means by which SAS communicates with the user concerning the processing of SAS statements. Information in the SAS Log informs the user of what data SAS has processed, what procedures have been run, and whether SAS has encountered any problems (errors or warnings) of which the user should be aware. The SAS Log is created each time a SAS job is run.

The SAS Output file (try1.lst) contains the output of any SAS PROCs executed by SAS (e.g., PROC PRINT, PROC GLM). The Output file is created only when PROC statements are executed as part of your SAS job.

Use the ls command to list the files in your directory. Note that you now have files named try1.log and try1.lst.

Step 3:

View the SAS Log and Output files using either Emacs (emacs try1.log, emacs try1.lst) or the more program (more try1.log, more try1.lst).

Step 4:

Print the Log and Output files (if you wish) using the lpr command (contact the NBCS/OIT Help Desk at 732-445-HELP for details on setting a preferred printer and bin for printed output).

     > lpr try1.log 
     > lpr try1.lst 

Running Time-Consuming SAS Jobs

When running the sample SAS job described above you probably noticed that the terminal prompt (>) did not re-appear until all SAS statements had been executed (i.e., until the job was finished). As a consequence, no additional programs (e.g., emacs, zmlite, etc.) could be run until SAS was finished. Although the small sample job you submitted resulted in only a short delay, larger and more time consuming jobs could tie up your terminal for long periods, thus preventing you from doing additional work.

In order to force the terminal prompt to re-appear immediately after the SAS job is submitted, the job must be submitted for background processing. A SAS job submitted for background processing runs while you use your terminal for running other programs.

To run a SAS job in the background, add an "&" to the end of the SAS command (e.g., sas try1 &). The system will display the process id (PID: a tracking number assigned by the computer's operating system) of the job and will then return you to the terminal prompt. You can then run other SAS jobs, run other programs, or logout. None of these actions will affect the SAS job running in the background.

To check on the status of a SAS job running in the background, use the ps (process status) command. The pscommand will display the process identification number (PID) of each process currently running and the name of the program associated with the process. If the PID for a SAS process is listed when you use the ps command, then that SAS process is still running. If the PID is not listed, the SAS process/job has completed and you may view the Log and Output files.


<hr>
Copyright © 2008 Rutgers, The State University of New Jersey, NBCS Help Desk. All rights reserved.

Rutgers Logo

webmaster@nbcs.rutgers.edu
06/22/05