Chapter Contents



Library Concatenation


Concatenation is the logical combining of two or more libraries. Concatenation allows 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 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, update, output, renames and deletes.

This example contains three SAS data libraries, and each data library contains two SAS data files. The LIBNAME statement concatenates LIB1, LIB2 and LIB3:

LIBNAME fruit (lib1 lib2 lib3);

LIB1            LIB2             LIB3
----            ----             ----
apples          apples           oranges
pears           oranges          plums

The concatenated library FRUIT has the following members:


Note:   Output will always go to the first level. For example: "data fruit.oranges" writes to LIB1.  [cautionend]

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

For complete documentation on library concatenation, see the LIBNAME statement or function in SAS Procedures Guide.

For more information on how specific operating environments handle concatenation, see the SAS documentation for your operating environment.

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:

Chapter Contents



Top of Page

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