something about SAS Catalog

www.signetsoft.com




Definition of a SAS Catalog

SAS catalogs are special SAS files that store many different kinds of information in smaller units called catalog entries. Each entry has an entry type that identifies its purpose to SAS. A single SAS catalog can contain several types of catalog entries. Some catalog entries contain system information such as key definitions. Other catalog entries contain application information such as window definitions, help windows, formats, informats, macros, or graphics output. You can list the contents of a catalog using various SAS features, such as SAS Explorer and PROC CATALOG.



SAS Catalog Names


Parts of a Catalog Name
SAS catalog entries are fully identified by a four-level name in the following form:
libref.catalog.entry-name.entry-type
You commonly specify the two-level name for an entire catalog, as follows:
libref.catalog
libref
is the logical name of the SAS library to which the catalog belongs.
catalog
is a valid SAS name for the file.
The entry name and entry type are required by some SAS procedures. If the entry type has been specified elsewhere or if it can be determined from context, you can use the entry name alone. To specify entry names and entry types, use this form:
entry-name.entry-type
entry-name
is a valid SAS name for the catalog entry.
entry-type
is assigned by SAS when the entry is created.

Accessing Information in Catalogs
In Base SAS software, SAS catalog entries are generally accessed automatically by SAS when the information stored in them is required for processing. In other SAS software products, you must specify the catalog entry in various procedures. Because the requirements differ with the SAS procedure or software product, refer to the appropriate procedure or product documentation for details.

Tools for Managing SAS Catalogs

There are several SAS features to help you manage the entries in catalogs. The CATALOG procedure and the CEXIST function are two features of Base SAS software. Another tool is SAS Explorer, which enables you to view the contents of SAS catalogs. Many interactive windowing procedures contain a catalog directory window for managing entries. The following list summarizes the tools that are available for managing catalogs:
CATALOG procedure
is similar to the DATASETS procedure. Use the CATALOG procedure to copy, delete, list, and rename entries in catalogs.
CEXIST function
enables you to verify the existence of a SAS catalog or catalog entry. See the CEXIST function in SAS Language Reference: Dictionary for more information.
CATALOG window
is a window that you can access at any time in an interactive windowing environment. It displays the name, type, description, and date of last update for each entry in the specified catalog. CATALOG window commands enable you to edit catalog entries. You can also view and edit catalog entries after double-clicking on a catalog file in SAS Explorer.
catalog directory windows
are available in some procedures in SAS/AF, SAS/FSP, and SAS/GRAPH software. A catalog directory window lists the same kind of information that the CATALOG window provides: entry name, type, description, and date of last update. See the description of each interactive windowing procedure for details about the catalog directory window for that procedure.



Profile Catalog

Definition of a Profile Catalog
Profile catalog (Sasuser.Profile) is a catalog that is available for customizing the way you work with SAS. SAS uses this catalog to store function key definitions, fonts for graphics applications, window attributes, and other information from interactive windowing procedures.

How the Information Is Used
The information in the Sasuser.Profile catalog is accessed automatically by SAS when you need it for processing. For example, each time you enter the KEYS window and change the settings, SAS stores the new settings with the KEYS entry type. Similarly, if you change and save the attributes for interactive window procedures, the changes are stored under the appropriate entry name and type. When you use the window or procedure, SAS then looks for information in the Profile catalog.

How Sasuser.Profile Is Created
SAS creates the Profile catalog the first time it tries to refer to it and discovers that it does not exist. If you are using an interactive windowing environment, this occurs during system initialization in your first SAS session. If you use one of the other modes of execution, the Profile catalog is created the first time you execute a SAS procedure that requires it.
At SAS startup, SAS checks for an existing uncorrupted Sasuser.Profile catalog. If this catalog is found, then SAS copies the Sasuser.Profile catalog to SASUSER.PROFBACK. The backup is used if the Sasuser.Profile catalog becomes corrupted. For more information, see How to Recover Locked or Corrupt Profile Catalogs.
Operating Environment Information:   The Sasuser library is implemented differently in various operating environments. See the SAS documentation for your host system for more information about how the SAS user library is created.  [cautionend]

Default Settings
The default settings for your SAS session are stored in several catalogs in the Sashelp installation library. If you do not make any changes to key settings or other options, SAS uses the default settings. If you make changes, the new information is stored in your Sasuser.Profile catalog. To restore the original default settings, use the CATALOG procedure or the CATALOG window to delete the appropriate entries from your Profile catalog. By default, SAS then uses the corresponding entry from the Sashelp library.
During SAS sessions, you can make customizations, such as window resizing and positioning, and save them to Sasuser.Profile.

How to Recover Locked or Corrupt Profile Catalogs
Occasionally, a Sasuser.Profile catalog becomes locked or corrupted. SAS uses SASHELP.PROFILE and SASUSER.PROFBACK to replace the locked or corrupted catalog.
If your Sasuser.Profile catalog is locked, SAS will check for SASHELP.PROFILE. If SASHELP.PROFILE exists, SAS copies it to WORK.PROFILE and then saves the customizations in Work.Profile instead of in Sasuser.Profile. The following notes will appear in the SAS log:
  ERROR: Expecting page 1, got page -1 instead.
  ERROR: Page validation error while reading SASUSER.PROFILE.CATALOG.
  NOTE: Unable to open SASUSER.PROFILE. WORK.PROFILE will be opened instead.
  NOTE: SASHELP.PROFILE has been copied to WORK.PROFILE.
  NOTE: All profile changes will be lost at the end of the session.
If your Sasuser.Profile catalog is corrupted, SAS copies the corrupted catalog to SASUSER.BADPRO. SAS then checks for SASUSER.PROFBACK. If SASUSER.PROFBACK exists, SAS copies it to Sasuser.Profile. Any changes made to the Sasuser.Profile catalog during the previous session will be lost. The following notes will appear in the SAS log:
ERROR: Expecting page 1, got page -1 instead.                                   
ERROR: Page validation error while reading SASUSER.PROFILE.CATALOG.             
NOTE: A corrupt SASUSER.PROFILE has been detected. A PROFILE catalog can        
      become corrupt when a SAS session is prematurely terminated.              
NOTE: SASUSER.PROFILE.CATALOG has been renamed to SASUSER.BADPRO.CATALOG.       
NOTE: SASUSER.PROFILE.CATALOG has been restored from SASUSER.PROFBAK.CATALOG.   
NOTE: Changes made to SASUSER.PROFILE.CATALOG during the previous SAS session   
      have been lost. The type of data stored in the PROFILE catalog is         
      typically related to SAS session customizations such as key               
      definitions, fonts for graphics, and window attributes.
If your Sasuser.Profile catalog is corrupted and there is no SASUSER.PROFBACK, SAS will check for SASHELP.PROFILE. If SASHELP.PROFILE exists, SAS copies it to WORK.PROFILE and then saves the customizations in Work.Profile instead of in Sasuser.Profile. The following notes will appear in the SAS log:

  ERROR: Expecting page 1, got page -1 instead.
  ERROR: Page validation error while reading SASUSER.PROFILE.CATALOG.
  NOTE: Unable to open SASUSER.PROFILE. WORK.PROFILE will be opened instead.
  NOTE: SASHELP.PROFILE has been copied to WORK.PROFILE.
  NOTE: All profile changes will be lost at the end of the session.


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 library1Members of library2
MYCAT.CATALOGMYCAT.CATALOG
TABLE1.DATAMYCAT2.CATALOG
TABLE3.DATATABLE1.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 library1Contents of MYCAT.CATALOG in library 2
A.FRAMEA.GRSEG
C.FRAMEB.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 library1Members of library2
MYCAT.CATALOGMYDOG.CATALOG
TABLE1.DATAMYCAT2.CATALOG
TABLE3.DATATABLE1.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 1MYDOG.CATALOG  library 2
A.FRAMEA.GRSEG
C.FRAMEB.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.
  •  When a catalog entry is open for input or update, the parts are searched and the first occurrence of the specified entry is used.
  •  When an item is open for output, it will be created in the catalog that is listed first in the concatenation.
    Note:   A new catalog entry is created in the first catalog even if there is an item 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]
  • 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 the catalog entry is shown.
    Note:   Even if a catalog entry occurs multiple times in the concatenation, only the first occurrence is shown.
    (courtesy: sas.com)
    Signetsoft is the Best Training institute in Bangalore for SAS, Clinical Research, Clinical Data Management, Clinical SAS, SAS Projects, Java, J2EE, Oracle, SQL, PL/SQL, Cognos, Informatica, Advanced Excel, VBA etc… For further details...
    please visit: www.Signetsoft.com , Bangalore
    or mails us :  info@signetsoft.com
     
    All the classes are fully practical and 100% job oriented.
    Thanks for visiting our blog.

Comments

  1. This is the exact information I am been searching for, Thanks for sharing the required infos with the clear update and required points. To appreciate this I like to share some useful information.MSBI Training in Bangalore

    ReplyDelete
  2. Thank you for sharing an amazing & wonderful blog. This content is very useful, informative and valuable in order to enhance knowledge. Keep sharing this type of content with us & keep updating us with new blogs. Apart from this, if anyone who wants to join the SAS Training institute in Delhi, can contact 9311002620 or visit our website-
    https://www.htsindia.com/Courses/business-analytics/sas-training-institute-in-delhi

    ReplyDelete

Post a Comment

Popular posts from this blog