Chapter Contents

Previous

Next
SAS Companion for UNIX Environments

Assigning Librefs with the LIBNAME Statement

Use the LIBNAME statement to associate a libref with a SAS data library. The general form of the LIBNAME statement is

LIBNAME libref <engine> 'SAS-data-library' <options> <engine/host-options>;
LIBNAME libref <engine> ('library-1<,...'library-n'>) <options>;
LIBNAME libref ('library-1'|libref- 1 ... 'library-n'|libref-n);
LIBNAME libref CLEAR | _ALL_ CLEAR;
LIBNAME libref LIST| _ALL_ LIST;

libref
is any valid libref as doc umented in SAS Language Reference: Dictionary.

The SAS System reserves some librefs for special system libraries. See Librefs Assigned by SAS for more information.

engine
is one of the library engines supported under UNIX. Details describes the two types of engines: library engines and view engines. See Engine Names and Descriptions for engine names and descriptions. If no engine name is specified, the SAS System determines which engine to use as described in Omitting Engine Names From the LIBNAME Statement.

'SAS-data-library'
differs according to the engine name that you specify and according to your current working directory. Engine Names and Descriptions describes what each engine expects for this argument. Specify directory pathnames as described in Specifying Pathnames. You cannot create directories with the LIBNAME statement. The directory that you specify must already exist. Enclose the data library name in quotes. Remember that UNIX filenames are case-sensitive.

'library-n' |libref-n
are pathnames or librefs (that have already been assigned) for the data libraries that you want to access with the same libref. Use these forms of the LIBNAME statement when you want to concatenate data libraries. Separate the pathnames with either commas or blank spaces. Enclose library pathnames in quotes. Do not enclose librefs in quotes. See Assigning a Libref to Several Directories (Concatenating Directories) for more information.

options
are LIBNAME statement options that are available in all operating environments. See SAS Language Reference: Dictionary for information about these options.

engine/host-options
can be any of the options described in Engine/Host Options.

_ALL_
refers to all librefs currently defined. You can use this keyword when you are listing or clearing librefs.

CLEAR
clears the specified libref or, if you specify _ALL_, clears all librefs that are currently defined. SASUSER, SASHELP, and WORK remain assigned.

Note:   When you clear a libref defined by an environment variable, the variable remains defined, but it is no longer considered a libref. You can still reuse it, either as a libref or a fileref. See Using Environment Variables as Librefs for more information.  [cautionend]

The SAS System automatically clears the association between librefs and their respective data libraries at the end of your job or session. If you want to associate an existing libref with a different SAS data library during the current session, you do not have to end the session or clear the libref. The SAS System automatically reassigns the libref when you issue a LIBNAME statement for the new SAS data library.

LIST
prints to the SAS log the engine, pathname, file format, access permissions, and so on, that are associated with the specified libref or, if you specify _ALL_, prints this information for all librefs that are currently defined. Librefs defined as environment variables appear only if you have already used those librefs in a SAS statement.

The association between the libref and the SAS data library lasts as long as the SAS job or session, unless you use the LIBNAME statement either to clear the association or to associate the libref with another SAS data library.

Engine Names and Descriptions describes each of the engines that you can specify in the LIBNAME statement and tells what each engine expects for the SAS-data-library argument.

Engine Names and Descriptions
Engine Type Name (alias) Description SAS-data-library
default V8 (BASE)

V7

enables you to create new SAS data files and access existing SAS data files that were created with Version 7 or Version 8. The V7 and V8 engines are identical. This engine enables read access to data files created with some earlier versions of SAS, but this engine is the only one that supports Version 7 and Version 8 catalogs. This engine allows for data set indexing and compression and is also documented in SAS Language Reference: Dictionary. is the pathname of the directory containing the library.
sequential V8TAPE

(TAPE)

V7TAPE

V6TAPE

accesses SAS data files that were created in a sequential format, whether on tape or on disk. This engine requires less overhead than the default engine because sequential access is simpler than random access. This engine is also documented in SAS Language Reference: Dictionary. is the name of the special file (see Introduction to External Files and Devices) that is associated with the sequential device, such as /dev/rmt/0mn.
compatibility V6 accesses any data file created by Release 6.09 through 6.12. is the pathname of the directory containing the library.
servers SPDS enables communication between a client session and a data server. You must have the Scalable Performance Data Server licensed on your client machine to use this engine. Refer to Scalable Performance Data Server User's Guide, Version 2 for more information. is the logical LIBNAME domain name for an SPDS data library on the server machine. The name server resolves the domain name into the physical path for the library.

MDDB enables communication between a client session and an MDDB server. You must have SAS/MDDB Server licensed either or your client machine or on your server machine to use this engine. Refer to SAS MDDB Server Software: Administration Guide for complete information.
transport XPORT accesses transport data sets. This engine creates machine-independent SAS transport files that can be used under all hosts running Release 6.09 or later of the SAS System. This engine is documented in Moving and Accessing SAS Files across Operating Environments. is the pathname of either a sequential device or a disk file.
interface BMDP provides read-only access to BMDP files. This engine is available only on AIX, HP-UX, and Solaris. is the pathname of the data file.

OSIRIS provides read-only access to OSIRIS files. is the pathname of the data file.

SPSS provides read-only access to SPSS files is the pathname of the data file.


Engine/Host Options

The LIBNAME statement accepts the FILELOCKS option:

FILELOCKS=NONE|FAIL|CONTINUE
This option specifies whether file locking is on or off for the library that you are defining. This LIBNAME statement option works like the FILELOCKS system option, except that it applies only to the library that you are defining. See FILELOCKS for more information.

You can also specify any of the options supported by the SPDS engines. SPDS is the Scalable Performance Data Server. Refer to Scalable Performance Data Server User's Guide, Version 2 for a description of these options.


Omitting Engine Names From the LIBNAME Statement

It is always more efficient to specify the engine name than to have the SAS System determine the correct engine. However, if you omit an engine name in the LIBNAME statement or if you define an environment variable to serve as a libref, the SAS System determines the appropriate engine.

If you have specified the ENGINE= system option, SAS uses the engine name that you specified. See ENGINE for a discussion of the ENGINE= system option.

Note:   The ENGINE= system option specifies the default engine for data libraries on disk only.  [cautionend]
If you did not specify the ENGINE= system option, SAS looks at the extensions of the files in the given directory and uses these rules to determine an engine:


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.