SAS Libraries |
Introduction to SAS System Libraries |
Four special SAS-supplied libraries provide convenience, support, and customization capability:
WORK Library |
The WORK library is the temporary (scratch) library that is automatically defined by SAS at the beginning of each SAS session. The WORK library stores two types of temporary files: those that you create and those that are created internally by SAS as part of normal processing. Typically, the WORK library is deleted at the end of each SAS session if the session terminates normally.
To store or retrieve SAS files in the WORK library, specify a one-level name in your SAS program statements. The libref WORK is automatically assigned to these files as a system default unless you have assigned the USER libref. The following examples contain valid names for SAS data sets stored in the WORK library:
Operating Environment Information: The WORK library is implemented differently in various operating environments. See the SAS documentation for your operating environment for more information.
While the WORK library is designed to hold temporary files used during the current SAS session, the USER library is designed to hold files after the SAS session is over. If you associate the libref USER with a SAS library, use a one-level name to create and access files that are not deleted at the end of your SAS session. When SAS encounters a one-level filename, it looks first in the USER library, if it has been defined, and then it looks in WORK. If you want to place a file in the USER library, so that it is not deleted after your SAS session is over, any single-level file goes there by default. At that point, if you want to create a temporary file in WORK, you must use a two-level name, such as WORK.NAME.
USER Library |
The USER library enables you to read, create, and write to files in a SAS library other than WORK without specifying a libref as part of the SAS filename. Once you associate the libref USER with a SAS library, SAS stores any file with a one-level name in that library. Unlike the WORK library, files stored in this library are not deleted by SAS when the session terminates.
You can assign the USER libref using one of the following methods:
In this example, the LIBNAME statement is used with a DATA step, which stores the data set REGION in a permanent SAS library.
libname user 'SAS-library'; data region; ... more DATA step statements ... run;
In this example, the LIBNAME function assigns the USER libref:
data _null_; x=libname ('user', 'SAS-library'); run;
When assigning a libref using the USER= system option, you must first assign a libref to a SAS library, then use the USER= system option to specify that library as the default for one-level names. In this example, the DATA step stores the data set PROCHLOR in the SAS library TESTLIB.
libname testlib 'SAS-library'; options user=testlib; data prochlor; ... more DATA step statements ... run;
Operating Environment Information: The methods and results of assigning the USER libref vary slightly from one operating environment to another. See the SAS documentation for your operating environment for more information.
The USER libref overrides the default libref WORK for one-level names. When you refer to a file by a one-level name, SAS looks first for the libref USER. If USER is assigned to a SAS library, files with one-level names are stored there. If you have not assigned the libref USER to a library, the files with one-level names are stored in the temporary library WORK. To refer to SAS files in the WORK library while the USER libref is assigned, you must specify a two-level name with WORK as the libref. Data files that SAS creates internally still go to the WORK library.
SASHELP Library |
Each SAS site receives the SASHELP library, which contains a group of catalogs and other files containing information that is used to control various aspects of your SAS session. The defaults stored in this library are for everyone using SAS at your installation. Your personal settings are stored in the SASUSER library, which is discussed later in this section.
If SAS products other than Base SAS are installed at your site, the SASHELP library contains catalogs that are used by those products. In many instances, the defaults in this library are tailored to your site by your on-site SAS support personnel. You can list the catalogs stored at your site by using one of the file management utilities discussed later in this section.
SASUSER Library |
The SASUSER library contains SAS catalogs that enable you to tailor features of SAS for your needs. If the defaults in the SASHELP library are not suitable for your applications, you can modify them and store your personalized defaults in your SASUSER library. For example, in Base SAS, you can store your own defaults for function key settings or window attributes in a personal profile catalog named SASUSER.PROFILE.
SAS assigns the SASUSER library during system initialization, according to the information supplied by the SASUSER system option.
A system option called RSASUSER enables the system administrator to control the mode of access to the SASUSER library at installations that have one SASUSER library for all users and that want to prevent users from modifying it.
Operating Environment Information: In most operating environments, the SASUSER library is created if it does not already exist. However, the SASUSER library is implemented differently in various operating environments. See the SAS documentation for your operating environment for more information.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.