Statements |
Valid: | Anywhere |
Category: | Data Access |
Syntax |
CATNAME <libref.> catref
< (libref-1.catalog-1 <(ACCESS=READONLY)> <...libref-n.catalog-n <(ACCESS=READONLY)>)> ; |
CATNAME <libref.> catref CLEAR | _ALL_ CLEAR; |
CATNAME <libref.> catref LIST | _ALL_ LIST; |
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. |
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 can be used for this catref.
is the name of a catalog that is available for use in the catalog concatenation.
Options |
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. |
disassociates all currently assigned catref or libref.catref concatenations.
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. |
writes all catalog names that are included in any current catalog concatenation to the SAS log.
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 |
CATNAME is useful because it enables you to access entries in multiple catalogs by specifying a single catalog reference name (libref.catref or catref). After you create a catalog concatenation, you can specify the catref in any context that accepts a simple (non-concatenated) catref.
To use catalog concatenation effectively, you must understand the rules that determine how catalog entries are located among the concatenated catalogs:
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.
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.
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.
When you want to delete or rename a catalog entry, only the first occurrence of the entry is affected.
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.
Comparisons |
The CATNAME statement is like a LIBNAME statement for catalogs. The LIBNAME statement allows you to assign a shortcut name to a SAS library so that you can use the shortcut name to find the files and use the data they contain. CATNAME allows you to assign a short name <libref.>catref (libref is optional) to one or more catalogs so that SAS can find the catalogs and use all or some of the entries in each catalog.
The CATNAME statement explicitly concatenates SAS catalogs. You can use the LIBNAME statement to implicitly concatenate SAS catalogs.
Examples |
You might need to access entries in several SAS catalogs. The most efficient way to access the information is to logically concatenate the catalogs. Catalog concatenation enables access to the information without actually creating a new, separate, and possibly very large catalog.
Assign librefs to the SAS libraries that contain the catalogs that you want to concatenate:
libname mylib1 'data-library-1'; libname mylib2 '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);
The SAS log displays this message:
Log Output from CATNAME Statement
NOTE: Catalog concatenation WORK.ALLCATS has been created.
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
After you create a concatenated catalog, you can use CATNAME to combine your concatenation with other single catalogs or other concatenated catalogs. Nested catalog concatenation 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, you could work on private copies of your application entries by using PRIVATE_CATALOG. If you want to see how your entries function when they are combined with the public version of the application, you can use COMBINED_CATALOGS.
See Also |
|
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.