Customizing Your SAS Session by Using Configuration and Autoexec Files

Customizing Your SAS Session

You can customize your SAS environment in several ways. To customize your SAS environment at the point of invocation, you can use configuration and autoexec files. For information about how to customize a SAS session using the windowing environment, see Overview of Customizing SAS in X Environment.

Introduction to Configuration and Autoexec Files

Defining Configuration and Autoexec Files

You can customize your SAS session by defining configuration and autoexec files. You can use these files to specify system options and to execute SAS statements automatically whenever you start a SAS session. SAS system options control many aspects of your SAS session, including output destinations, the efficiency of program execution, and the attributes of SAS files and libraries. For a complete description of SAS system options, see SAS System Options: Reference.
For SAS 9.3, the configuration file is typically named sasv9.cfg, and the autoexec file is named autoexec.sas. These files typically reside in the directory where SAS was installed. By default, this directory is the !SASROOT directory.
You can have customized configuration and autoexec files in your user home directory. If you do, then SAS will use the customizations specified in these files when you start a SAS session. For more information about the order of precedence SAS uses when processing configuration files, see Order of Precedence for Processing SAS Configuration Files.
SAS system options can be restricted by a UNIX system administrator, so that once they are set by the administrator, they cannot be changed by a user. A system option can be restricted globally, by group, and by user. For more information, see the configuration guide for the UNIX environment on the Technical Support Web site, and see Restricted Options in SAS System Options: Reference.

Using the AUTOEXEC System Option

The AUTOEXEC system option specifies the autoexec file. The autoexec file contains SAS statements that are executed automatically when you invoke SAS, or when you start another SAS process. The autoexec file can contain any SAS statements. For example, your autoexec file can contain LIBNAME statements for SAS libraries that you access routinely in SAS sessions.
SAS looks for the AUTOEXEC system option in the following places. It uses the first AUTOEXEC system option that it finds.
  • in the command line
  • in the SASV9_OPTIONS environment variable
  • in the configuration file
If neither the AUTOEXEC nor NOAUTOEXEC system option is found, SAS looks for the autoexec file in three directories in the following order:
  1. your current directory
  2. your home directory
  3. the !SASROOT directory (for more information, see The !SASROOT Directory)
SAS uses the first autoexec file that it finds to initialize the SAS session. If you want to see the contents of the autoexec file for your session, use the ECHOAUTO system option when you invoke SAS.

Inserting and Appending Autoexec Files

You can concatenate files in your autoexec file by using the following system options with the AUTOEXEC system option:INSERT System Option: UNIX and APPEND System Option: UNIX. The autoexec file is always a UNIX file. If your filename contains embedded blanks or special characters, you must enclose the filename in quotation marks. Otherwise, quotation marks are optional when one or more filenames are specified.
You can use the following syntax to concatenate autoexec files:
-autoexec "(/path1/autoexec.sas /path2/autoexec.sas /path3/autoexec.sas)"
You can use the following syntax with the INSERT system option:
-insert autoexec "a.sas" –insert autoexec "b.sas"
You can use the following syntax with the APPEND system option:
-append autoexec "a.sas" –append autoexec "b.sas"
If any file in a concatenated autoexec list does not exist or cannot be opened (for example, if you are not authorized for Read access), SAS issues error messages to the log. SAS terminates without executing any of the files in the list. The final SAS exit code is 103, which indicates system start-up failure.

Differences between Configuration and Autoexec Files

The differences between configuration files and autoexec files are as follows:
  • Configuration files can contain only SAS system option settings, while autoexec files can contain any valid SAS statement. For example, you might want to create an autoexec file that includes an OPTIONS statement to change the default values of various system options and LIBNAME and FILENAME statements for the SAS libraries and external files that you use most often.
  • Configuration files are processed before SAS initializes, while autoexec files are processed immediately after SAS initializes but before it processes any source statements. An OPTIONS statement in an autoexec file is equivalent to submitting an OPTIONS statement as the first statement of your SAS session.

Creating a Configuration File

To create a configuration file, follow these steps:
  1. Use a text editor to write the SAS system options into a UNIX file. Save the file as either sasv9.cfg or .sasv9.cfg. (For more information, see Order of Precedence for Processing SAS Configuration Files.)
  2. Specify one or more system options on each line. Use the same syntax that you would use for specifying system options with the SAS command, but do not include the SAS command itself. For example, a configuration file might contain the following lines:
    -nocenter
    -verbose
    -linesize 64
    -work /users/myid/tmp
  3. Save and close the configuration file.

Order of Precedence for Processing SAS Configuration Files

SAS is shipped with a default configuration file in the !SASROOT directory. Your on-site SAS personnel can edit this configuration file so that it contains whichever options are appropriate to your site.
You can also create one or more of your own configuration files. SAS reads option settings from each of these files in the following order:
  1. sasv9.cfg in the !SASROOT directory. (See Contents of the !SASROOT Directory.)
  2. sasv9_local.cfg in the !SASROOT directory. (See Contents of the !SASROOT Directory.)
  3. .sasv9.cfg in your home directory. (Notice the leading period.)
  4. sasv9.cfg in your home directory.
  5. sasv9.cfg in your current directory.
  6. any restricted configuration files. Restricted configuration files contain system options that are set by the site administrator and cannot be changed by the user. Options can be restricted globally, by group, or by user. For more information about restricted configuration files, see the configuration guide for the UNIX environment.
For future releases of SAS, the names of these files will change accordingly.
For each system option, SAS uses the last setting that it encounters. Any other settings are ignored. For example, if the WORKPERMS system option is specified in sasv9.cfg in the !SASROOT directory and in sasv9.cfg in your current directory, SAS uses the value specified in sasv9.cfg in your current directory.

Specifying a Configuration File for SAS to Use

When you specify a configuration file for SAS to use, you bypass the search of the configuration files listed in Order of Precedence for Processing SAS Configuration Files.
Note: SAS still processes any restricted configuration files that exist. The settings in these files take precedence over the settings in the configuration file that you specify.
If you set both SASV9_OPTIONS and SASV9_CONFIG, SAS always uses SASV9_OPTIONS. SASV9_CONFIG is used only if you do not use –config in the command line.
To specify a configuration file, complete one of the following steps:
filename is the name of a file that contains SAS system options.
If you have specified a configuration file in the SASV9_OPTIONS or SASV9_CONFIG environment variables, you can prevent SAS from using that file by specifying NOCONFIG in the SAS command.
If SAS cannot find SASV9_OPTIONS, the following message is written to the SAS log:
ERROR: Cannot open [/fullpath/filename]: No such
       file or directory.