Library Names


Library Names

Physical Names and Logical Names (Librefs)

Before you can use a SAS data library, you must tell SAS where it is. SAS recognizes SAS data libraries based on either operating environment naming conventions or SAS naming conventions. There are two ways to define SAS data libraries.

  • a physical location name that the operating environment recognizes

  • a logical name (libref) that you assign using the LIBNAME statement, LIBNAME function, or the New Library window.

The physical location name of the SAS data library is a name that identifies your SAS files to the operating environment. The physical location name must conform to the naming conventions of your operating environment. The physical location name fully identifies the directory, or operating environment data set that contains the SAS data library.

The logical name, or libref , is the way you identify a group of files to SAS. A libref is a name that you associate with the physical location of the SAS data library.

Assigning Librefs

Librefs can be assigned using the following methods :

  • LIBNAME statement

  • LIBNAME function

  • New Library window that is available in your toolbar

  • operating environment commands.

Once the libref is assigned, you can read, create, or update files in a data library. A libref is valid only for the current SAS session, unless it is assigned using the New Library window with the Enable at startup box checked.

A libref can have a maximum length of eight characters . You can use the LIBREF function to verify that a libref has been assigned. Librefs can be referenced repeatedly within a SAS session. SAS does not limit the number of librefs you can assign during a session; however, your operating environment or site may set limitations. If you are running in batch mode, the library must exist before you can allocate or assign it. In interactive mode, you may be allowed to create it if it does not already exist.

Operating Environment Information: Here are examples of the LIBNAME statement for different operating environments. The rules for assigning and using librefs differ across operating environments. See the SAS documentation for your operating environment for specific information.

Table 26.1: Syntax for Assigning a Libref

Operating Environment

Examples

DOS, Windows

  libname mylibref 'c:\root\mystuff\sasstuff\work';  

UNIX

  libname mylibref '/u/mystuff/sastuff/work';  

UNIX System Services under z/OS

  libname mylibref '/mystuff/sastuff/work';  

z/OS

  libname mylibref 'userid.mystuff.sastuff.work';  

OpenVMS Alpha

  libname mylibref 'filename filetype filemode';  

You can also access files without using a libref. See 'Accessing Permanent SAS Files without a Libref' on page 478.

Associating and Clearing Logical Names (Librefs) With the LIBNAME Statement

You can assign or clear a physical name with a libref using the LIBNAME statement or the LIBNAME function, which are described in the SAS Language Reference: Dictionary .

Operating Environment Information: For some operating environments, you can use operating environment commands to associate a libref with a SAS data library. When using operating environment commands to assign librefs to a SAS data library, the association may persist beyond the SAS session in which the libref was created. For some operating environments you can use only the LIBNAME statement or function. See the SAS documentation for your operating environment for more information on assigning librefs.

The most common form of the LIBNAME statement is used in this example to associate the libref ANNUAL with the physical name of the SAS data library.

 libname annual '  SAS-data-library'  ; 

If you use the LIBNAME statement to assign the libref, SAS clears (deassigns) the libref automatically at the end of each SAS session. If you want to clear the libref ANNUAL before the end of the session, you can issue the following form of the LIBNAME statement:

 libname annual clear; 

SAS also provides a New Library window to assign or clear librefs and SAS Explorer to view, add or delete SAS data libraries. You can select the New Library or the SAS Explorer icon from the Toolbar.

Reserved Librefs

SAS reserves a few names for special uses. You should not use SASHELP, SASUSER or SASWORK as librefs, except as intended. The purpose and content of these libraries are discussed in 'Permanent and Temporary Libraries' on page 473.

Operating Environment Information: There are other librefs reserved for SAS under some operating environments. In addition, your operating environment may have reserved certain words that cannot be used as librefs. See the SAS documentation for your operating environment for more information.




SAS 9.1 Language Reference. Concepts
SAS 9.1 Language Reference Concepts
ISBN: 1590471989
EAN: 2147483647
Year: 2004
Pages: 255

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net