Previous Page | Next Page

SAS Catalogs

Catalog Concatenation


Definitions

You can logically combine two or more SAS catalogs by concatenating them. This enables you to access the contents of several catalogs, using one catalog name. There are two ways to concatenate catalogs, using the LIBNAME statement and CATNAME statement.

LIBNAME catalog concatenation

results from a concatenation of libraries through a LIBNAME statement. When two or more libraries are logically combined through concatenation, any catalogs with the same name in each library become logically combined as well.

CATNAME catalog concatenation

is a concatenation that is specified by the global CATNAME statement in which the catalogs to be concatenated are specifically named. During CATNAME catalog concatenation, a logical catalog is set up in memory.


Example 1: LIBNAME Catalog Concatenation

This LIBNAME statement concatenates the two SAS libraries:

libname both ('SAS-library 1''SAS-library 2' );

Members of library1 Members of library2
MYCAT.CATALOG MYCAT.CATALOG
TABLE1.DATA MYCAT2.CATALOG
TABLE3.DATA TABLE1.DATA

TABLE1.INDEX

TABLE2.DATA

TABLE2.INDEX

The concatenated libref BOTH would have the following:

Concatenated libref BOTH
MYCAT.CATALOG (from path 1 and 2)
MYCAT2.CATALOG (from path 2)
TABLE1.DATA (from path 1)
TABLE2.DATA (from path 2)
TABLE2.INDEX (from path 2)
TABLE3.DATA (from path 1)

Notice that TABLE1.INDEX does not appear in the concatenation but TABLE2.INDEX does appear. SAS suppresses listing the index when its associated data file is not part of the concatenation.

So what happened to the catalogs when the libraries were concatenated? A resulting catalog now exists logically in memory, with the full name BOTH.MYCAT.CATALOG. This catalog combines each of the two physical catalogs residing in 'library 1' and 'library2', called MYCAT.CATALOG.

To understand the contents of the concatenation BOTH.MYCAT, first look at the contents of both parts of the concatenation. Assume that the two original MYCAT.CATALOG files contain the following:

Contents of MYCAT.CATALOG in library1 Contents of MYCAT.CATALOG in library 2
A.FRAME A.GRSEG
C.FRAME B.FRAME

C.FRAME

Then the combined catalog BOTH.MYCAT contains the following:

BOTH.MYCAT
A.GRSEG (from path 2)
A.FRAME (from path 1)
B.FRAME (from path 2)
C.FRAME (from path 1)


Example 2: CATNAME Catalog Concatenation

The syntax of the CATNAME statement is:

CATNAME libref.catref
          (libref-1.catalog-1 (ACCESS=READONLY)
           libref-n.catalog-n (ACCESS=READONLY));

To disassociate a concatenated catalog the syntax is:

CATNAME libref.catref | _ALL_ clear;

In the following example, there must be a libref that is defined and named CATDOG. The libref CATDOG establishes the scope for the CATNAME concatenation definition.

Note:   If a file in CATDOG named COMBINED.CATALOG already exists, it becomes inaccessible until the CATNAME concatenation CATDOG.COMBINED is cleared.  [cautionend]

Members of library1 Members of library2
MYCAT.CATALOG MYDOG.CATALOG
TABLE1.DATA MYCAT2.CATALOG
TABLE3.DATA TABLE1.DATA

TABLE1.INDEX

TABLE2.DATA

TABLE2.INDEX

If we issue the following statement,

CATNAME catdog.combined
          (library1.mycat (ACCESS=READONLY)
           library2.mydog (ACCESS=READONLY));

then the concatenated catalog CATDOG.COMBINED combines the following catalogs:

Concatenated catalog CATALOG.COMBINED
MYCAT.CATALOG (from library 1)
MYDOG.CATALOG (from library 2)

Note:   In CATNAME concatenation only the named catalogs are combined. In LIBNAME concatenation, any catalogs that have the same name in their respective libraries are concatenated when those libraries are concatenated.  [cautionend]

The previous CATNAME statement creates a catalog that exists logically in memory. This catalog, named CATDOG.COMBINED.CATALOG, combines the two physical catalogs residing in library1 and library2, called MYCAT.CATALOG and MYDOG.CATALOG respectively.

To understand the contents of the concatenation COMBINED.CATALOG, first look at the contents of both parts of the concatenation. The two original catalog files contain the following entries:

MYCAT.CATALOG
library 1
MYDOG.CATALOG
library 2
A.FRAME A.GRSEG
C.FRAME B.FRAME

C.FRAME

The concatenated catalog COMBINED contains:

COMBINED.CATALOG contents
A.GRSEG (from MYDOG)
A.FRAME (from MYCAT)
B.FRAME (from MYDOG)
C.FRAME (from MYCAT)


Rules for Catalog Concatenation

The rules for catalog concatenation are the same, whether the catalogs are concatenated using the LIBNAME statement or the CATNAME statement.

Previous Page | Next Page | Top of Page