Chapter Contents

Previous

Next
SAS Companion for the OpenVMS Operating Environment

Using SAS in Batch Mode

SAS batch mode is equivalent to OpenVMS batch mode. It is useful for SAS programs that require large amounts of time and memory. In batch mode, you submit a job to an OpenVMS batch queue, and the job awaits execution along with batch jobs that have been submitted by other OpenVMS users. The amount of time before your job executes depends on how many other jobs are in the input queue, on what priority the operating environment has assigned to your job, and how your batch queue(s) is configured.

You can use your terminal for other tasks while the job awaits execution, but you cannot change the submitted job in any way until after it executes.

Usually, the first step in executing a program in batch mode is to prepare two types of files:

command procedure file
contains the DCL commands that are used to set up the SAS environment. For example, it may include commands that do the following:

program file
contains the SAS program that you want to execute. The name of this file can be included in the text of the command procedure file, or it can be passed as a parameter to the command procedure file. See the examples in Examples of Batch Job Files.


Examples of Batch Job Files

Following are three examples of using command procedure files and program files in batch mode.

Example 1: Separate Command Procedure and Program Files

In this example, we first create a file called MYPROG.SAS that contains the following simple SAS program:

libname in 'disk:[directory]';
proc print data=in.mydata;
   title 'A Simple SAS Program';
run;

Next we create a command procedure file called CONTROL.COM that contains the following DCL command:

$ SAS8/LINESIZE=76/NODATE [HOME.SUBDIR]MYPROG.SAS
CAUTION:
Do not give your SAS program and the command procedure the same name. Giving them the same name causes confusion when both the OpenVMS log and the SAS log are created. The OpenVMS log is created first (for example, MYPROG.LOG;1) and the SAS log is created second (MYPROG.LOG;2). If your OpenVMS system has been set up to keep only one version of a file, then the OpenVMS batch log will be overwritten by the SAS log.  [cautionend]

To submit the SAS job, we enter the following command at the DCL prompt:

$ SUBMIT/NOTIFY CONTROL.COM

The job is placed in the default batch queue, and the terminal session is available for other work. You will be notified by the operating environment when your batch job has completed.

Example 2: Passing the Name of the Program File as a Parameter

You can make your command procedure file more generic and pass the name of the SAS program as a parameter. This is helpful if you want to execute several programs in the same environment. To do this, you would modify the command procedure file from Example 1 as follows:

$ SAS8/LINESIZE=76/NODATE  'P1'

The 'P1' at the end of the SAS command line is the placeholder for the parameter that you are going to pass to the command.

You could then submit a program called MYPROG.SAS by executing the following command:

$ SUBMIT/NOTIFY/PARAMETER=("MYPROG.SAS")-
_$ CONTROL.COM

Example 3: Including the Program File in the Command Procedure File

A third alternative is to include the SAS program in the same file as the control commands. In a batch environment, the OpenVMS system assumes that the input source is the command procedure file that is executing. This input source is named by the OpenVMS logical name SYS$INPUT. To combine the control commands and the SAS program in the same file, create a command file that contains the following lines:

$ SAS8/LINESIZE=76/NODATE-
   /PRINT=DISK:[DIRECTORY]MYPROG.LIS-
   /LOG=DISK:[DIRECTORY]MYPROG.LOG SYS$INPUT
libname in 'disk:[directory]';
proc print data=in.mydata;
   title 'A Simple SAS Program';
run;

endsas;

The hyphen at the end of the first line of the SAS command indicates that the command continues on the next line. Designating SYS$INPUT as your input file tells SAS that your input will be included in the text of the command procedure file. Submit this job as you would any other batch job at your site.


Chapter Contents

Previous

Next

Top of Page

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