Using the Work Library
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:
proc contents data=testdata;
proc contents data=work.testdata;
Operating Environment Information
The Work library is implemented differently in various operating environments. See
the SAS documentation for your operating environment for more information.
Relation to the User Library
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.
Definition of 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.
Ways to Assign the User Libref
You can assign the User libref using one of the following methods:
• LIBNAME statement
• LIBNAME function
• USER= system option
• operating environment command
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';
... more DATA step statements ...
In this example, the LIBNAME function assigns the User libref:
x=libname ('user', 'SAS-library');
594 Chapter 26 • SAS Libraries