A LIBNAME statement is used in a SAS program to associate a "library
reference name" with an external
SAS data library whose members include
SAS data sets and SAS cataloges.
The general form of the SAS LIBNAME statement is:
LIBNAME libref 'lib_path' ;
Where:
- LIBNAME is the SAS language statement used to
associate a library reference name with an external SAS data library.
- libref is a name used within the SAS program to
refer to the external data library defined within the single quotes of the
LIBNAME statement.
- 'lib_path' is the full specification of the
SAS data library. In most environments, the entity refered to
within the single quotes must exist prior to issuing the LIBNAME
statement.
Note: If a data set is defined or used without specifying a "LIBNAME",
the default LIBNAME of "WORK" is assumed. When "WORK" data sets are
created during a SAS job, they are typically deleted when you exit from the
SAS environment.
- In PC Windows (3.1, 95, and NT)
environments, the SAS Data
Library is the name of a subdirectory.
If the library is not a subdirectory of the default
directory, you must specify the full path for the data library.
For example, the following LIBNAME statement will associate library
reference 'anyname' with the SAS data library
'd:\lib_path\mydata\test.dat':
LIBNAME anyname 'd:\lib_path\mydata\test.dat' ;
- In UNIX,
environments, the SAS Data
Library is the name of a subdirectory.
If the library is not a subdirectory of the default
directory, you must specify the full path for the data library.
For example, the following LIBNAME statement will associate library
reference 'anyname' with the SAS data library
'/home/userid/lib_path/mydata':
LIBNAME anyname '/home/userid/lib_path/mydata' ;
- In the Macintosh,
environments, the SAS Data Library is the name of a folder
If the library is not a subdirectory of the default folder,
you must specify the full folder path for the data library.
For example, the following LIBNAME statement will associate library
reference 'anyname' with the SAS data library
in the folder mydata contained within the folder
lib_path within the drive 'Macintosh HD':
LIBNAME anyname 'Macintosh HD:lib_path:mydata' ;
- If you are using the mainframe
MVS System, you can use either the LIBNAME statement in your SAS
program or a DD statement in the JCL to assign a library reference
name to the SAS data library. See
Using SAS Data Sets in the MVS Environment for additional information.
- In VM/CMS, filemode 'A' is assumed as the default
SAS data library. In this environment, you only need to specify a
LIBNAME statement if the SAS data library refers to a different
minidisk. If you are using minidisk 'D' for your SAS data
library, you could use the following LIBNAME statement:
LIBNAME anyname 'D' ;
Note: The VTVM1 System was discontinued Dec. 1st, 1999.