Associates or disassociates a SAS data library with a libref (a
shortcut name); clears one or all librefs; lists the characteristics of a
SAS data library; concatenates SAS data libraries; implicitly concatenates
SAS catalogs.
| Valid: |
Anywhere
|
| Category: |
Data Access
|
| See Also: |
LIBNAME, SAS/ACCESS
|
LIBNAME libref
<engine> 'SAS-data-library'
< options >
<engine/host-options>;
|
LIBNAME libref CLEAR | _ALL_
CLEAR;
|
LIBNAME libref LIST | _ALL_
LIST;
|
![[4]]( ../common/images/sym04.gif) LIBNAME libref <engine> (library-specification-1
<. . . library-specification-n>)
< options > ;
|
-
libref
-
is a shortcut name or a "nickname"
for the aggregate storage location where your SAS files are stored. It is
any SAS name when you are assigning a new libref. When you are disassociating
a libref from a SAS data library or when listing attributes, specify a libref
that was previously assigned.
-
'SAS-data-library'
-
must be the physical name for the SAS data
library. The physical name is the name that is recognized by the operating
environment. Enclose the physical name in single or double quotation marks.
Operating Environment Information:
For details on specifying the physical
names of files, see the SAS documentation for your operating environment.
In some operating environments, you can use an operating
environment command, the LIBNAME statement, or the LIBNAME function to associate
the libref with the SAS data library. In others, you must use an operating
environment command. See the SAS documentation for your operating environment
for more information.
-
library-specification
-
is two or more SAS data libraries, specified
by physical names, previously-assigned librefs, or a combination of the two.
Separate each specification with either a blank or a comma and enclose the
entire list in parentheses.
-
'SAS-data-library'
-
the physical name of a SAS data library,
enclosed in quotation marks.
-
libref
-
is the name of a previously-assigned libref.
-
engine
-
is an engine name.
-
CLEAR
-
disassociates one or more currently assigned
librefs.
-
_ALL_
-
specifies that the CLEAR or LIST argument
applies to all currently-assigned librefs.
-
LIST
-
writes the attributes of one or more SAS
data libraries to the SAS log.
-
ACCESS=READONLY|TEMP
-
Operating Environment Information:
Some
operating environments support LIBNAME statement options that have similar
functions to the ACCESS= option. See the SAS documentation for your operating
environment. ![[cautend]](../common/images/cautend.gif)
-
OUTREP=default-format
-
specifies the default format for the SAS
data library that is specified. New data sets that are stored in this SAS
data library are written in this format. Existing data sets that are written
to the library are given the new format. Values for OUTREP= are
-
TRANTAB=translation-table
-
specifies the translation table to use for
character conversions. When any data set in a format foreign to the host is
written to the specified SAS data library, SAS uses the specified translation
table.
Operating Environment Information:
For
a list of valid specifications, see the SAS documentation for your operating
environment. ![[cautend]](../common/images/cautend.gif)
-
engine-host-options
-
are one or more options listed in the general
form keyword=value.
Operating Environment Information:
For
a list of valid specifications, see the SAS documentation for your operating
environment.
The association between a libref and a SAS data library
lasts only for the duration of the SAS session or until you change it or discontinue
it with another LIBNAME statement. The simplest form of the LIBNAME statement
specifies only a libref and the physical name of a SAS data library:
|
LIBNAME libref
'SAS-data-library';
|
See Assigning and Using a Libref.
An engine specification
is usually not necessary. If
the situation is ambiguous, SAS uses the setting of the ENGINE= system option
to determine the default engine. If all data sets in the library are associated
with a single engine, SAS uses that engine as the default. In either situation,
you can override the default by specifying another engine with the ENGINE=
option:
LIBNAME libref engine
'SAS-data-library'
<options >
<engine/host-options>;
|
Operating Environment Information:
Using
the LIBNAME statement requires host-specific information. See the SAS documentation
for your operating environment before using this statement.
To disassociate a libref from a SAS data library, use
a LIBNAME statement, specifying the libref and the CLEAR option. You can clear
a single, specified libref or all current librefs.
|
LIBNAME libref CLEAR | _ALL_ CLEAR;
|
Use a LIBNAME statement to write the attributes of one
or more SAS data libraries to the SAS log. Specify libref
to list the attributes of one SAS data library; use _ALL_ to list the attributes
of all SAS data libraries that have been assigned librefs in your current
SAS session.
|
LIBNAME libref LIST | _ALL_ LIST;
|
When you logically concatenate two or more SAS data
libraries, you can reference them all with one libref. You can specify a library
with its physical pathname or its previously assigned libref.
|
LIBNAME libref
<engine> (library-specification-1 <. . . library-specification-n>)
< options > ;
|
|
In the same LIBNAME statement you can use any combination
of specifications: librefs, physical pathnames, or a combination of librefs
and pathnames. See Logically Concatenating SAS Data Libraries.
When you logically concatenate two or more SAS data
libraries, you also implicitly concatenate the SAS catalogs that have the
same name. For example, if three SAS data libraries each contain a catalog
named CATALOG1, then when you concatenate them, you implicitly create a catalog
concatenation for the catalogs that have the same name. See Implicitly Concatenating SAS Catalogs.
|
LIBNAME libref <engine> (library-specification-1 <. . .
library-specification-n>)
< options > ;
|
|
After you create a library concatenation, you can specify
the libref in any context that accepts a simple (nonconcatenated) libref.
These rules determine how SAS files (that is, members of SAS libraries) are
located among the concatenated libraries:
-
When a SAS file is opened for input or update,
the concatenated libraries are searched and the first occurrence of the specified
file is used.
-
When a SAS file is opened for output, it is created
in the first library that is listed in the concatenation.
Note:
A new SAS file is created in the first library even if there is a file with
the same name in another part of the concatenation. ![[cautend]](../common/images/cautend.gif)
-
When you delete or rename a SAS file, only the
first occurrence of the file is affected.
-
Any time a list of SAS files is displayed, only
one occurrence of a file name is shown.
Note:
Even if
the name occurs multiple times in the concatenation, only the first occurrence
is shown.
-
A SAS file that is logically connected to another
file (such as an index to a data set) is listed only if the parent file resides
in that same library. For example, if library ONE contains A.DATA, and library
TWO contains A.DATA and A.INDEX, only A.DATA from library ONE is listed. (See
rule 4.)
-
If any library in the concatenation is sequential,
then all of the libraries are treated as sequential.
-
The attributes of the first library that is specified
determine the attributes of the concatenation. For example, if the first SAS
data library that is listed is "read only", then the entire concatenated
library is "read only".
-
If you specify any options or engines, they apply
only to the libraries that you specified with the complete physical name,
not to any library that you specified with a libref.
-
If you alter a libref after it has been assigned
in a concatenation, it will not affect the concatenation.
This example assigns the libref SALES to an aggregate
storage location that is specified in quotation marks as a physical pathname.
The DATA step creates SALES.QUARTER1 and stores it in that location. The PROC
PRINT step references it by its two-level name, SALES.QUARTER1.
libname sales 'SAS-data-library';
data sales.quarter1;
infile 'your-input-file;
input salesrep $20. +6 jansales febsales
marsales;
run;
proc print data=sales.quarter1;
run;
This example concatenates three SAS data libraries by
specifying the physical filename of each and assigns the libref ALLMINE to
the concatenated libraries:
libname allmine ('path-1' 'path-2'
'path-3');
If each library contains a SAS catalog named MYCAT,
then using ALLMINE.MYCAT as a libref.catref provides access to the catalog
entries that are stored in all three catalogs named MYCAT. To logically concatenate
SAS catalogs with different names, see CATNAME.
If you want the convenience of specifying only a one-level
name for permanent, not temporary, SAS files, use the USER= system option.
This example stores data set QUARTER1 permanently without using a LIBNAME
statement first to assign a libref to a storage location:
options user='SAS-data-library';
data quarter1;
infile 'your-input-file;
input salesrep $20. +6 jansales febsales
marsales;
run;
proc print data=quarter1;
run;
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.