SASĀ® in UNIX Batch Mode

It is very important to know before we begin SASĀ® with Unix that UNIX operating system is case sensitive. When we execute SAS command files from the UNIX prompt, it is called batch processing. The basic concept of SAS batch mode operation in this kind of circumstance is that, rather than having your local PC constantly asking for things from the server, you just run SAS on the server directly without having to send information back to your local PC. The best part is we can do scheduling the date/time for SAS programs to be executed.

Run SAS Program in Batch Mode

SAS not only can be run in a GUI (SAS Enterprise Guide), but also in a batch mode.

To run SAS in batch, one must do the following step:

– Invoking SAS program

– Submit SAS program in Batch Quene

– View SAS output

We need to specify SAS program name in the SAS invocation command. The best thing is that we can even run a batch mode in the background by specifying an ampersand (&) at the end of the SAS command, or by submitting SAS application to the batch queue by

usingĀ batch,Ā at,Ā nohup orĀ cronĀ UNIX commands (refer to Unix man page for more detail).

The benefit of using these commands is that if you start your application with one of these UNIX commands and you log off of your system, then your application will complete execution.

Note:

Ā If we used FSEDIT procedures or any other interactive procedures to be started in our application, then you need to run your batch application in the foreground.

Invoking SAS in Batch Mode

For invoking SAS in batch mode, you must specify a filename in the SAS command. For example, ifĀ Program1.sasĀ is the file that contains the SAS statements to be executed then you would enter the following command:

>sas <command_file>

Submitting a Program to the Batch Queue

There are basically two Ways to Submit a Batch Job and Manage OutputĀ ā€“

The below command will submit the sas in batch for immediate execution –

Ā Ā Ā Ā Ā Ā Ā Ā  >sas Program1.sasĀ 

To submit your program to the batch queue, you can use the at commands. A scheduled job is created by entering AT followed by the time, occurrences, date and the command to be executed. For example, you could submitĀ Program1.sasĀ from your shell prompt as follows:

> at 10:00 sas Program1.sas

Windows will automatically assign a number to the job (Program1.sas). You will see this number when you use AT to display the active jobs. You will need to use this number in the command line if you want to delete the job from the active list.

Also, time should be entered in 24 hour military time format (i.e.: 22:00 for 10pm). The number of occurrences is specified by the keyword /next: or /every:. Use /next: to schedule the job to run only once. Use /every: for repetitive jobs. For example, we need to schedule a job to run at 10 pm every Tuesday and Thursday ā€“

> at 22:00 /every:Tu,Th sas Program1.sas

View SAS output

The results are written to two files log (.log) and output (.lst) files for viewing at a later time. The SAS log is written to the UNIX file called income1.log. The SAS listing is written to the UNIX file called income1.lst. To view the output, type:

>more Program1.log

>more Program1.lst

This can speed up the amount of time it takes to execute a SAS program since it does not also need to write the output to the screen for display. You can then add options, such as-log mysaslog.logĀ and such to redirect the log (if you don’t, then the log goes to the location where the sas program file is located with same name).

Related Articles:

All About SASĀ® OnDemand
Understanding and Writing SASĀ® Stored Process
ANOVA & Chi Square Using the Language of SAS- Part 1

 

Interested in learning about other Analytics and Big Data tools and techniques? Click on our course links and explore more.
Jigsawā€™s Data Science with SAS Course –Ā click here.
Jigsawā€™sĀ Data Science with R CourseĀ –Ā click here.
Jigsaw’s Big Data Course – click here.

Ā 

Related Articles

loader
Please wait while your application is being created.
Request Callback