|SAS Companion for UNIX Environments
If you want to read or write to a
SAS file, you can refer to the SAS file in one of two ways:
A libref is a nickname that you can use to refer to the
data library during the SAS session or job. You will probably want to use
a libref when:
- refer to the data file directly by using its pathname
in the appropriate statements (such as DATA, SET, MERGE, UPDATE, OUTPUT, and
- assign a libref to the SAS data library (directory)
that contains the data file and use the libref as the first level of a two-level
You can assign a libref with the LIBNAME statement or through the New Library
window in the Explorer. To open the New Library window, select
- the data file pathname is long and must be specified
several times within a program
- the pathname might change. If the pathname changes,
you need to change only the statement assigning the libref, not every reference
to the file.
- your application will be used on other platforms.
Using librefs makes it easier to port an application to other operating environments.
- you need to concatenate libraries. See
Assigning a Libref to Several Directories (Concatenating Directories) for more information.
can also use an environment variable as the libref.
After you have defined a libref, you can use the libref
in one of two ways to access a permanent SAS data library:
For example, these SAS statements access the data file
in the library in the the directory
- as the first level of a two-level SAS file
where libref is the first-level name
referring to the directory where the file is stored, and member-name specifies the name of the file being read or created.
- as the
value of the USER= option. (See USER Data Library for details.)
libname sales '/users/myid/mydir';
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.