Batch Mode in UNIX Environments


Introduction to Running SAS in Batch Mode

To run SAS in batch mode, you specify your SAS application name in the SAS command. You can run batch mode in the foreground, in the background by specifying an ampersand at the end of the SAS command, or submit your application to the batch queue by using the batch , at , nohup ,or cron UNIX commands. (For more information, refer to the UNIX man pages for the batch , at , nohup ,or cron commands.) If you start your application with one of these UNIX commands and you log off of your system, then your application will complete execution. If your application contains statements that start an interactive procedure such as FSEDIT, then you need to run your batch application in the foreground.

Invoking SAS in Batch Mode

To invoke SAS in batch mode, you must specify a filename in the SAS command. For example, if Weekly.rpt is the file containing the SAS statements to be executed, and you want to specify the NODATE and LINESIZE system options, you would enter

 sas weekly.rpt -nodate -linesize 90 

The command would run the program in the foreground. If you want to run the program in the background, add the ampersand to the end of the command:

 sas weekly.rpt -nodate -linesize 90 & 

You do not need to specify the SYSIN option as with some other platforms.

SAS creates a .log file and a .lst file in the current directory that contains the log and procedure output.

Submitting a Program to the Batch Queue

To submit your program to the batch queue, you can use the batch , at , nohup , or cron commands. For example, you could submit Weekly.rpt from your shell prompt as follows :

 $ at 2am   sas weekly.rpt   <control-D>   warning: commands will be executed using /usr/bin/sh   job 8400.a at Wed Jun 11 02:00:00 2003   $ 

If you create a file that contains the SAS command necessary to run your program, for example CmdFile.sas, then you can enter the following command at your shell prompt:

 at 2am < cmdfile.sas 

SAS sends the output to a file that has the same name as the program and an extension of .lst, and the log goes to a file with an extension of .log. Both of these files are written to your current directory. Refer to the man pages for these commands for more information on submitting jobs to the batch queue. For more details on routing output, see Chapter 6, "Printing and Routing Output," on page 153.

Note  

If your program contains statements that start an interactive procedure such as the FSEDIT procedure, you will need to run your program in the foreground.

Writing Data From an External File using Pipes

You can use a pipe to write data from an external file to a SAS program. For example, suppose that your data resides in the file MyData and your program MyProg.sas includes this statement:

 INFILE STDIN; 

Issue this command to have MyProg.sas read data from MyData:

 cat mydata  sas myprog.sas 

For details about using external files, see Chapter 5, "Using External Files and Devices," on page 131. See also "File Descriptors in the Bourne and Korn Shells" on page 140 for another way to have a SAS program read data from an external file.




SAS 9.1 Companion for UNIX Environments
SAS 9.1 Companion For Unix Enivronments
ISBN: 1590472101
EAN: 2147483647
Year: 2004
Pages: 185
Authors: SAS Institute

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net