Previous Page | Next Page

SAS Libraries

Library Concatenation


Definition of Library Concatenation

Concatenation is the logical combining of two or more libraries. Concatenation enables you to access the SAS data sets in several libraries with one libref.

You can concatenate two or more libraries by specifying their librefs or physical names in the LIBNAME statement or function.

Physical names must be enclosed in single or double quotation marks in a LIBNAME statement. Otherwise SAS looks for a previously assigned libref with the same name.

In the following examples, summer, winter, spring, fall, and annual are previously defined librefs:

libname annual (summer winter spring fall);

libname annual ('path1' 'path2' 'path3');

libname annual ('path' winter spring fall);

libname total (annual 'path');


How SAS Concatenates Library Members

When there are members of the same name in more than one library, the first occurrence of the member is used for input and update processes. Output will always go to the first library.

This example contains three SAS libraries, and each library contains two SAS data files:

LIB1

APPLES and PEARS

LIB2

APPLES and ORANGES

LIB3

ORANGES and PLUMS

The LIBNAME statement concatenates LIB1, LIB2, and LIB3:

libname fruit (lib1 lib2 lib3);

The concatenated library FRUIT has the following members:

APPLES

PEARS

ORANGES

PLUMS

Note:   Output will always go to the first library. For example, the following statement writes to the first library in the concatenation, LIB1:

data fruit.oranges;

  [cautionend]

Note that in this example, if the file APPLES in LIB1 was different from the file APPLES in LIB2, and if an update to APPLES was specified, it will be updated only in LIB1 because that is the first occurrence of the member APPLES.

For complete documentation on library concatenation, see the LIBNAME statement or function in SAS Language Reference: Dictionary.

Operating Environment Information:   For more information about how specific operating environments handle concatenation, see the SAS documentation for your operating environment.  [cautionend]


Rules for Library Concatenation

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:

Previous Page | Next Page | Top of Page