Chapter Contents

Previous

Next
SAS Companion for UNIX Environments

Using SAS in Batch Mode

To invoke the SAS System 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 &

The SAS command uses .sas by default, so if your filename ends with .sas, you do not need to include the extension in the SAS command. (Also, you do not need to specify the SYSIN option as in some other platforms.)

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

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 10 02:00:00 1998
$
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
The SAS System 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 Routing Output.

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.  [cautionend]

You can also 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 on using external files, see Using External Files and Devices. See also File Descriptors in the Bourne and Korn Shells for another way to have a SAS program read data from an external file.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.