Chapter Contents

Previous

Next
CATNAME

CATNAME



Logically combines two or more catalogs into one by associating them with a catref (a shortcut name); clears one or all catrefs; lists the concatenated catalogs in one concatenation or in all concatenations

Valid: Anywhere
Category: Data Access
See Also: LIBNAME statement; FILENAME, CATALOG statement


Syntax
Arguments
Options
Details
Why Use CATNAME?
Rules for Catalog Concatenation
Comparisons
Examples
Example 1: Assigning and Using a Catalog Concatenation
Example 2: Creating a Nested Catalog Concatenation
See Also

Syntax

[1]CATNAME<libref.> catref
<(libref-1.catalog-1 <(ACCESS=READONLY)>
<...libref-n.catalog-n <(ACCESS=READONLY)>)> ;
[2]CATNAME <libref.> catref CLEAR | _ALL_ CLEAR;
[3]CATNAME <libref.> catref LIST | _ALL_ LIST;

Arguments

libref
is any previously-assigned SAS libref. If you do not specify a libref, SAS concatenates the catalog in the work library, using the catref that you specify.
Restriction: The libref must have been previously assigned.

catref
is a unique catalog reference name for a catalog or a catalog concatenation that is specified in the statement. Separate the catref from the libref with a period, as in libref.catref. Any SAS name may be used for this catref.

catalog
is the name of a catalog to be made available for use in the catalog concatenation.


Options

CLEAR
disassociates a currently assigned catref or libref.catref.
Tip: Specify a specific catref or libref.catref to disassociate it from a single concatenation. Specify _ALL_ CLEAR to disassociate all currently assigned catref or libref.catref concatenations.

_ALL_ CLEAR
disassociates all currently assigned catref or libref.catref concatenations.

LIST
writes the catalog names that are included in the specified concatenation to the SAS log.
Tip: Specify catref or libref.catref to list the attributes of a single concatenation. Specify _ALL_ to list the attributes of all catalog concatenations in your current session.

_ALL_ LIST
writes all catalog names that are included in any current catalog concatenation to the SAS log.

ACCESS=READONLY
assigns a read-only attribute to the catalog. SAS, therefore, will allow users to read from the catalog entries but not to update information or to write new information.


Details

Why Use CATNAME?

CATNAME is useful because it allows you to access entries in multiple catalogs by specifying a single catalog reference name (libref.catref or just catref). After you create a catalog concatenation, you can specify the catref in any context that accepts a simple (nonconcatenated) catref.

Rules for Catalog Concatenation

To use catalog concatenation effectively, you must understand the rules that determine how catalog entries are located among the concatenated catalogs:

  1. When a catalog entry is opened for input or update, the concatenated catalogs are searched and the first occurrence of the specified entry is used.

  2. When a catalog entry is opened for output, it will be created in the first catalog that is listed in the concatenation.

    Note:   A new catalog entry is created in the first catalog even if there is an entry with the same name in another part of the concatenation.  [cautionend]

    Note:   If the first catalog in a concatenation that is opened for update does not exist, the item will be written to the next catalog that exists in the concatenation.  [cautionend]

  3. When you want to delete or rename a catalog entry, only the first occurrence of the entry is affected.

  4. Any time a list of catalog entries is displayed, only one occurrence of a catalog entry name is shown.

    Note:   Even if the name occurs multiple times in the concatenation, only the first occurrence is shown.  [cautionend]


Comparisons


Examples

Example 1: Assigning and Using a Catalog Concatenation

As an example, you may need to access entries in several SAS catalogs. The most efficient way to access the information is to logically concatenate the catalogs. This allows access to the information without actually creating a new, separate, possibly very large catalog.

Assign libnames to the SAS data libraries that contain the catalogs that you want to concatenate:

libname mylib1 'my-data-library-1';
libname mylib2 'my-data-library-2';
 

Assign a catref, which can be any valid SAS name, to the list of catalogs that you want to logically concatenate:

 catname allcats (mylib1.catalog1 mylib2.catalog2);

Because no libref is specified, the libref is WORK by default. When you want to access a catalog entry in either of these catalogs, use the libref WORK and the catalog reference name ALLCATS instead of the original librefs and catalog names. For example, to access a catalog entry named APPKEYS.KEYS in the catalog MYLIB1.CATALOG1, specify

work.allcats.appkeys.keys

Example 2: Creating a Nested Catalog Concatenation

Once you have created a concatenated catalog, you can use CATNAME to combine your concatenation with other single catalogs or other concatenated catalogs. This is useful, because you can use a single catref to access many different catalog combinations.

libname local 'my_dir';
libname main  'public_dir';


catname private_catalog (local.my_application_code
                         local.my_frames 
                         local.my_formats);

catname combined_catalogs (private_catalog
                         main.public_catalog);

In the above example, an application developer could be working on private copies of his/her application entries by using PRIVATE_CATALOG. If the same user wanted to see how his/her entries functioned when they were combined with the public version of the application, that user could find out by using COMBINED_CATALOGS.

See Also

Statements:
Statements
FILENAME, CATALOG Access Method
LIBNAME for a discussion of implicitly concatenating SAS catalogs.


Chapter Contents

Previous

Next

Top of Page

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