Files Used by SAS

Introduction to Files Used by SAS

SAS uses many files while it is running. However, some of these files, such as the following, are especially important from a user's perspective.
  • SAS configuration files (SASVx.CFG by default, where x is the release number)
  • SAS autoexec file (AUTOEXEC.SAS by default)
  • user Profile catalog (Profile.sas7bcat)
  • user printer Profile catalog (Profile2.sas7bcat)
  • Work data library (“SAS Temporary Files” folder in your system's designated TEMP area)
  • SAS Registry Files.

SAS Configuration Files

Purpose of Configuration Files

The SAS configuration file enables you to specify SAS system options that are used to establish your SAS session. These system options indicate, among other things, the location of your SAS Help and Documentation files as well as the location of message files and the pathnames to SAS executable files. The SAS configuration file is particularly important because it specifies the folders that are searched for the various components of SAS products. You must have at least one configuration file in order for SAS to initialize; you can have multiple configuration files that are all processed while your SAS session begins. For more information about system options, see SAS System Options: Reference.

The Default Configuration File

In previous releases of SAS, the default configuration file was stored in the!SASROOT folder. The!SASROOT folder is the folder in which you install SAS. Starting with SAS 9, SAS creates two default configuration files during installation. Both configuration files are named SASV9.CFG.
In SAS 9.4, the location selected for SAS software installation is created and called SASHOME. !SASROOT is located at !SASHOME/SASFoundation/9.4. The default folder !SASHOME is located at c:\program files\SASHome. The default configuration location is c:\program files\SASHome\SASFoundation\9.4\nls\en\sasv9.cfg.
The SASV9.CFG file that is located in the!SASROOT folder contains a CONFIG system option that specifies the location of the configuration file for the SAS default language. The default system options that are used to start SAS are specified in the !SASROOT\nls\language-code\SASV9.CFG file. For example, if SAS is installed in the default folder and the default language is English, the SASV9.CFG file in the!SASROOT folder contains -config "c:\program files\SASHOME\SASFoundation\9.4\nls\en\sasv9.cfg"
SAS requires a configuration file, so you must use a SAS configuration file regardless of whether you are using interactive or batch mode.
SAS uses the default configuration file if you start SAS by double-clicking a registered SAS file type, such as .sas.
For more information about the !SASHOME folder, see SAS Default Folder Structure .

Specifying System Options in a Configuration File

Any system option can be specified when you start SAS. It is often more convenient to place frequently used system options in a configuration file. For details about the syntax for specifying system options in a SAS configuration file, see Syntax for System Options in the SAS Invocation or SAS Configuration File .
You can edit the default configuration file to add to or change the system option settings, or you can create your own configuration file. Creating a Customized Configuration File discusses how to modify your configuration file.
Your configuration file is divided into two sections. The first section specifies system options that are not updated by the SAS Setup application. The second section is used by the setup application for updating information about where SAS software is installed. The sections are divided by the following warning:
 WARNING:   INSTALL Application edits below this line. User
            options should be added above this box comment.
            INSTALL Application maintains and modifies the
            following options; -SASAUTO, -SASHELP, -SASMSG
            -PATH, and -MAPS. It also maintains and modifies
            the following CONFIG variables with the -SET option;
            INSTALL, USAGE, LIBRARY, SAMPSIO, SAMPSRC, SASCBT,
            and SASEXT01–SASEXT50. It preserves all lines above
            the line containing 'DO NOT EDIT BELOW THIS LINE'.
The setup application deletes all data below this warning but does not affect the options that are specified above it. The SET system option defines the following SAS environment variables: SASROOT, SASEXT0, SASFOLDER, MYSASFILES, SASCFG, SASAUTOS, SAMPSIO, SAMPSRC, EISIMAGE, and INSTALL. The setup application appends the following system options below this warning: SASUSER, WORK, HELPLOC, DMSEXP, APPLETLOC, TEXTURELOC, RESOURCESLOC, JREOPTIONS, SASSCRIPT, SASHELP, MSG, and PATH.
CAUTION:
To avoid corrupting your configuration file, use a SAS text editor or an ASCII text editor to edit your configuration file.
The text editor that you choose to edit the configuration file is important to preserve some of the special character formatting in the file. The recommended method is to edit your configuration file by using a SAS text editor (such as the Enhanced Editor) and save it by using the Save As dialog box. If you do not use a SAS text editor, be sure to use another ASCII text editor (such as Windows Notepad). Do not use a specialized editor such as the WordPad application or Microsoft Word. Using such editors can insert carriage-control characters into your configuration file or corrupt the characters.

Creating a Customized Configuration File

When you install SAS, a SASV9.CFG file is created in the !SASROOT\nls\language-code folder. The language-code is a two-letter language code for the SAS default language. You can specify your own file to act as the configuration file, thus overriding the default file, SASV9.CFG.
The filename that you choose must follow the file-naming conventions for the Windows operating environment. The file extension must be .CFG.
When you use your own configuration file instead of the default configuration file, you must add several required system options. For example, you must either use the SET system option to define the environment variable, !SASROOT, or define SASROOT as a Windows environment variable.
To ensure that all required system options are defined in your configuration file, copy the default file (!SASROOT\nls\language-code\SASV9.CFG) and modify the copy instead of creating your own file.
You can create a customized configuration file and name the file either SASV9.CFG or .SASV9.CFG in your Windows user profile folder. During SAS invocation, SAS looks for either of these files in the Windows user profile folder if the -CONFIG options are not specified. Under Windows, the path for the user profile folder is c:\Users\user-ID\Documents

Starting SAS with an Alternate Configuration File

When you use a file that is located in a different folder or that has a different name as your default configuration file, you must tell SAS where to find the configuration file. Use the CONFIG system option to specify the location of this configuration file. For example, the Target field of the SAS Properties dialog box might contain
“c:\program files\SASHome\SASFoundation\9.4\sas.exe -config c:\mysas\mysasconfig.CFG”
If SAS cannot find the configuration file, an error message is displayed, and SAS does not initialize.
For more information about the CONFIG system option, see Processing Options Specified by Additional CONFIG Options and CONFIG System Option: Windows .

How SAS Finds and Processes Configuration Files

When you invoke SAS, SAS automatically searches several locations for configuration options that can affect your SAS session. SAS looks in the following areas and processes them in this order:
SAS_SYS_CONFIG operation system environment variable
This environment variable, if defined, must resolve to a valid configuration file. In a multi-user Windows system, this environment variable would most likely be defined as a system environment variable (instead of as a user environment variable) so that it is processed for all users on that system. Use the SAS_USER_CONFIG user environment variable to specify a user-specific configuration file.
files specified by CONFIG system options
In the SAS invocation command, you can specify one or more -CONFIG options with the names of the configuration files that you want to use. You must include a separate -CONFIG option for each file that you want to specify.
SASVx.CFG in the folder where SAS.EXE resides
SAS looks for a file that is named SASVx.CFG (x is the SAS version number) in the folder that contains the SAS.EXE file only if you do not specify a -CONFIG option at SAS invocation. This configuration file contains only a CONFIG system option that specifies the configuration file for the SAS default language.
.SASVx.CFG in the Windows user profile folder
SAS looks for a file that is named .SASVx.CFG (x is the SAS version number) in the Windows user profile folder only if you do not specify a -CONFIG option at SAS invocation. Under Windows, the user profile folder is c:\Users\user-ID\Documents\.
SASVx.CFG in the Windows user profile folder
SAS looks for a file that is named SASVx.CFG (x is the SAS version number) in the Windows user profile folder only if you do not specify a -CONFIG option at SAS invocation. Under Windows, the user profile folder is c:\Users\user-ID\Documents\
SASVx.CFG in the current folder
SAS looks for a file that is named SASVx.CFG (x is the SAS version number) in the current folder only if you do not specify a -CONFIG option at SAS invocation.
SAS_USER_CONFIG operating system environment variable
This environment variable, if defined, must be a path to a valid SAS configuration file. In a multi-user Windows system, this environment variable would likely be defined as a user environment variable (instead of as a system environment variable) so that it is processed only for the current user on that system. Use the SAS_SYS_CONFIG system environment variable to specify a system-wide configuration file.
SAS_OPTIONS operating system environment variable
This environment variable, if defined, contains a string of option specifications for any other SAS system options that you want to process each time you invoke SAS. For example, this environment variable might contain -obs 2m -sasinitialfolder c:\myfolder -linesize max.
SAS invocation command line
You can specify additional system options in the command that you use to invoke SAS. These system options always override option values that are set within any of the configuration files.
If you start SAS from the Start menu, the last configuration file to be processed is the one that is specified in the Start menu shortcut for SAS. The options that are specified in this configuration file override any options that have previously been processed. By default, the Start menu shortcut specifies -config !SASROOT\nls\language-code\SASVx.CFG
SAS uses the default configuration file if you start SAS by double-clicking on a registered SAS file type, such as .sas or .sas7bpgm.
Order of Processing for SAS Configuration Files
Order of processing for SAS configuration files

Processing Options Specified by Additional CONFIG Options

You can also specify additional –CONFIG options within any configuration file. When SAS encounters a –CONFIG option, SAS immediately processes the options in that named file and then returns to process the remainder of the current file. SAS options that are encountered later in the processing always override those options that are specified earlier. For example, if you specify -ICON in the file that is specified by the SAS_SYS_CONFIG environment variable, and then –NOICON in the file that is specified by the SAS_USER_CONFIG environment variable, the –NOICON option is used. Since the options that you specify in the SAS invocation command are always processed last, those option values always override the option values that are specified in configuration files. Order of Processing for SAS Configuration Files illustrates the flow of the SAS configuration file processing.
For more information about the CONFIG system option, see CONFIG System Option: Windows .

SAS Autoexec File

Introduction to the SAS Autoexec File

The SAS autoexec file contains SAS statements that are executed immediately after SAS initializes and before any user input is accepted. These SAS statements can be used to invoke SAS programs automatically, set up certain variables for use during your SAS session, or set system options.
Use a SAS text editor to create your autoexec file. The text editor that you choose to create the autoexec file is important. The recommended method is to create the file by using a SAS text editor (such as the Enhanced Editor window) and save it using the Save As dialog box. If you do not use the SAS text editor, be sure to use another ASCII text editor (such as Windows Notepad). Do not use a specialized editor such as the WordPad application or Microsoft Word. Using such an editor can insert special carriage-control characters into your autoexec file that SAS cannot interpret when it tries to execute the statements in the file.

The Default Autoexec File

Unlike the configuration file, a SAS autoexec file is not required in order to run SAS. But, if you do have an autoexec file, the default name is AUTOEXEC.SAS. SAS uses the following search order to find the AUTOEXEC.SAS file:
  1. Search the current folder.
    Note: For information about determining the current folder, see: Determining the Current Folder When SAS Starts .
  2. Search the paths that are specified by the Windows PATH environment variable.
  3. Search the root folder of the current drive.
  4. Search the folder that contains the SAS.EXE file.
If an AUTOEXEC.SAS file is not present in one of these folders and if you did not specify the -AUTOEXEC option on the command line or within any of your configuration files, then SAS assumes that there is no autoexec file to process. For more information, see AUTOEXEC System Option: Windows .

Locating a Renamed Autoexec File

You do not have to name your autoexec file AUTOEXEC.SAS, but if you name it something else, you must use the AUTOEXEC system option to tell SAS where to find the autoexec file. For example, you can specify the following option after the path specification for the SAS.EXE file in the Target field of the SAS Windows shortcut:
-autoexec c:\mysasfiles\init.sas
If the specified autoexec file is not found, an error message is displayed, and SAS terminates.

Uses for the Autoexec File

The autoexec file is a convenient way to execute a standard set of SAS program statements each time you invoke SAS. You can include OPTIONS, LIBNAME, or FILENAME statements, or any other SAS statements and system options that you want the system to execute each time you invoke a SAS session. For example, if you want to specify a script file for SAS/CONNECT software, you can place the following statement in the AUTOEXEC.SAS file:
filename rlink 'c:\program files\SASHome\SASFoundation\9.4\connect\saslink\
startSession.scr';
Or you can use the OPTIONS statement to set the page size and line size for your SAS output and use several FILENAME statements to set up filerefs for commonly accessed network drives, as in the following example:
options linesize=80 pagesize=60;
filename saledata 'f:\qtr1';
filename custdata 'l:\newcust';
filename invoice 'o:\billing';
Other system options, in addition to the AUTOEXEC system option, provide ways to send SAS information as it is initializing. These options are listed below in the order in which they are processed:
  1. CONFIG (at SAS invocation only)
  2. AUTOEXEC
  3. INITCMD
  4. INITSTMT
  5. SYSIN
For more information about the CONFIG, AUTOEXEC, INITSTMT, and SYSIN system options, see SAS System Options under Windows . For more information about the INITCMD system option, see SAS System Options: Reference.

Suppressing the Autoexec File

If you have an AUTOEXEC.SAS file in your current folder, but you want to suppress it, specify the NOAUTOEXEC option in the SAS command, as in the following example:
c:\program files\SASHome\SASFoundation\9.4\sas.exe -noautoexec

Profile Catalog

Introduction to the Profile Catalog

Each time you invoke a SAS session, SAS checks the Sasuser data library for your user Profile catalog (named Sasuser.Profile), which defines the start-up profile for your SAS session, including key definitions, display configurations, and other personal customizations. If you invoke SAS without accessing an existing Profile catalog, SAS creates one with the default key definitions and window configuration.
If Sasuser.Profile does not exist and Sashelp.Profile (in the Sashelp data library) does exist, SAS copies Sashelp.Profile to Sasuser.Profile before invoking a SAS session.
The Profile catalog is not re-created if it already exists. Any customizations (such as key definitions or color modifications) that are defined during subsequent sessions are stored in your Profile catalog in the specified folder.

The Default Profile Catalog

The default configuration file for SAS specifies the SASUSER system option as follows:
The Default SASUSER Locations for the Windows Operating Environment
Windows 7 and 8, Windows Server 2008 and 2012
-sasuser "c:\Users\user-ID\Documents\My SAS Files\9.4"

Changing the Location of the Profile Catalog

Use the SASUSER system option to specify a location for the Profile catalog other than the default (which is a folder named \My SAS Files\9.4). This option is useful if you want to customize your SAS sessions when sharing a machine with other users or if users are accessing SAS from a network.
The SASUSER system option takes the following form:
-SASUSER ("library-specification")
Parentheses () are used to specify multiple library-specifications, and quotation marks (") are used when special characters and spaces are used in the library-specification.
If library-specification (which specifies a valid Windows pathname) does not exist, SAS attempts to create it. For example, if you specify the following option, a Profile catalog is created in a folder named MYUSER that resides in the root folder of the C: drive:
-sasuser "c:\myuser"
For more information, see SASUSER System Option: Windows .

Deleting the Profile Catalog

When you delete your Profile catalog, you lose the key definitions, window configurations, and option settings that you might have defined, as well as any other entries that you saved to your Profile catalog. In addition, any text that you stored in NOTEPAD windows is erased. For this reason, it is a good idea to make a backup copy of your Profile catalog after making significant modifications to your SAS session settings.

Work Data Library

Introduction to the Work Data Library

SAS requires some temporary disk space during a SAS session. This temporary disk space is called the Work data library. By default, SAS stores SAS files with one-level names in the Work data library, and these files are deleted when you end your SAS session. You can change the Work data library in which SAS files that have one-level names are stored. For more information, see Using the User Libref .

The Default Work Folder

The default configuration file for SAS specifies the WORK system option to be a folder in your system's designated temporary area (as defined by the TEMP environment variable). For example: !TEMP\SAS Temporary Files.
To determine TEMP environment variable, refer to the System Properties dialog box that you access from the Control Panel.
For more information about using the Work data library and overriding the default location, see Using the Work Data Library .

Specifying the Location of the Work Data Library

The WORK system option controls the location of the Work data library. You can specify the WORK option in your SAS configuration file or when you invoke SAS. Usually, you use the WORK option that is specified in the default configuration file.

Distributing Work Directories

SAS can make the distribution of Work libraries dynamic by distributing Work libraries across several directories. This functionality eliminates the potential problem of filling up a single volume with all of the Work directories. The WORK system option requires an argument, which must specify a .txt file that contains a list of directories that SAS uses for allocating Work libraries. Individual Work libraries reside in a single directory. The WORK system option is used in the sasv9.cfg configuration file or on the command line. When the argument WORK is a list of directories in a file, specify the method for choosing which directory to use for WORK. If you specify METHOD=RANDOM, then SAS chooses a directory from the list of available directories. If you specify METHOD=SPACE, then SAS chooses the directory that has the most available space.
For more information, see the WORK System Option: Windows .

Temporary Subfolders

Because you can run multiple SAS sessions at one time, SAS creates temporary subfolders under the folder that you specify with the WORK option. These temporary subfolders are created in the unique form _TDnnnnnnnnnn, where TD means temporary folder and nnnnnnnnnn is the process ID and nodename is the name of the host of the machine that created the folder. These subfolders enable multiple SAS sessions to be invoked, each using the same configuration file, and they prevent the Work folder from being shared. SAS creates any temporary files that are required within each temporary folder. As with all temporary files that are created in the Work data library during a SAS session, these temporary folders are deleted when you end the SAS session. If SAS terminates abnormally, you might need to delete the temporary files.

Deleting the Work Folder

If SAS terminates abnormally, determine whether the Work library was deleted. If not, remove it by using Windows commands.
Note: Do not attempt to delete the Work folder while SAS is running.
You can verify the location of the current Work folder by opening the Libraries folder in the SAS Explorer window. Click the right mouse button on the Work folder and select Properties from the pop-up menu.

SAS Registry Files

The SAS registry files are used to store information about the SAS session applications. The registry entries can be customized by using the SAS registry editor or by importing the registry files. To invoke the SAS registry editor, select Solutionsthen selectAccessoriesthen selectRegistry Editor.
CAUTION:
Incorrect registry entries can corrupt your SAS registry.
Registry customization is generally performed by more advanced users who have experience and knowledge of SAS and their operating environment.

SAS Default Folder Structure

The SAS Setup program creates a number of subfolders during the installation process. Understanding the organization of the SAS folders can help you use SAS more efficiently.
The root folder of SAS is the folder in which you install SAS. Within SAS, this folder has the logical name !SASHOME. SAS Foundation products are installed in a folder structure under SASHOME called SASROOT. If you use the default provided by SAS, the SASHOME folder is c:\Program Files\SASHOME\SASFoundation\9.4. (The examples in this document assume the !SASHOME folder is called c:\Program Files\SASHOME\SASFoundation\9.4.)
The 32-bit content on an X64 system is installed in c:\program files\SASHome\x86\SASFoundation\9.4
SAS creates a folder for shared components, such as the Enhanced Editor and images, that are used by other SAS products. For SAS 8, the default path for shared components is c:\Program Files\SAS Institute\Shared Files. For SAS 9 through 9.4, the default path for shared files, if shared components are installed, is c:\Program Files\SAS\Shared Files. If shared components are not installed, the default path is c:\Program Files\SAS\SharedFiles. There is no blank space in the spelling of SharedFiles.
One important subfolder of the !SASROOT folder is the CORE subfolder. The CORE subfolder contains many subfolders, three of which are described here:
!SASROOT\CORE\RESOURCE
contains SAS resources such as fonts and images.
!SASROOT\CORE\SAMPLE
contains the SAS sample programs.
!SASROOT\CORE\SASINST
contains the installation process software.
For each SAS product that is installed, the following subfolders might be created (not all products contain all of these folders):
!SASROOT\product\SASEXE
contains the SAS executable files.
!SASROOT\product\SASHELP
contains many specialized catalogs and files.
!SASROOT\product\SASMACRO
contains SAS autocall macro files.
!SASROOT\product\SASMSG
contains the SAS message files.
!SASROOT\product\SAMPLE
contains the Sample Library programs.
!SASROOT\product\SASTEST
contains Test Stream programs.
!SASROOT\product\SASMISC
contains miscellaneous external files shipped with the product.
Some products, such as SAS/CONNECT software, also have other subfolders that are associated with them. For details about each product's structure, see the specific SAS product documentation.
For more information about how the SAS folders are configured at your site, contact your on-site SAS support personnel.