Chapter Contents


SAS Companion for the CMS Environment

Autoexec Files

Unlike configuration files, which contain SAS system options, an autoexec file contains SAS statements. For example, an autoexec file could contain the following lines:

options nodate linesize=75;
libname mylib 'b';

In this example, the OPTIONS statement sets some SAS system options, and the LIBNAME statement assigns a libref.

Note:   Some SAS system options can be specified only when you invoke SAS. These system options cannot be specified in an OPTIONS statement; therefore, they cannot be specified in an autoexec file. Summary Table of SAS System Options tells where each SAS system option can be specified.  [cautionend]

Another difference between configuration files and autoexec files is that configuration files are processed before SAS is initialized, whereas autoexec files are processed after SAS is initialized. Therefore, setting the NODATE and LINESIZE= options in a configuration file affects the appearance of the SAS log header, whereas setting NODATE and LINESIZE= in an autoexec file does not. An OPTIONS statement in an autoexec file is equivalent to submitting an OPTIONS statement as the first statement of your SAS session.

Creating an Autoexec File

To create an autoexec file, follow these steps:

  1. Use any text editor to write SAS statements into a CMS file. If you use SAS as the filetype, then you will not need to specify the filetype in the AUTOEXEC= system option. (See Specifying an Autoexec File .)

  2. Type in the SAS statements that you want to include.

  3. Save the new autoexec file.

Specifying an Autoexec File

To tell SAS which autoexec file to use, use the AUTOEXEC= system option in the SAS command. For example, the following SAS command invokes SAS and tells it to use the autoexec file named MYEXEC SAS:

sas (autoexec=myexec

The SAS filetype is assumed. If your autoexec file has a different filetype, then you must specify the filetype, and you must enclose the file specification in quotation marks. For example, the following SAS command specifies the autoexec file named AUTO1 AUTOFILE.

sas (autoexec='auto1 autofile'

If you don't include a filemode in your file specification, then SAS searches your minidisks or SFS directories in standard CMS search order to locate the autoexec file.

Note:   Alternatively, you may include the filemode or an explicit SFS directory as a value in the AUTOEXEC= option. If you specify either, you must also specify a filetype.  [cautionend]

Displaying Autoexec Statements in the SAS Log

SAS statements that are submitted from an autoexec file usually are not displayed in the SAS log. However, if you specify the ECHOAUTO system option when you invoke SAS, then SAS writes (or "echoes") the autoexec statements to the SAS log as they are executed. For example, suppose your autoexec filename is MYEXEC FILE and that it contains the following SAS statements:

libname mylib 'b';
filename newdata 'myprog data c';

If you use the following command to invoke SAS, then the contents of MYEXEC FILE will be written to the SAS log.

sas (autoexec='myexec file' echoauto

For more information about the ECHOAUTO system option, see SAS Language Reference: Dictionary.

Chapter Contents



Top of Page

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