CATALOG Procedure

Concepts

Interactive Processing with RUN Groups

Definition

The CATALOG procedure is interactive. Once you submit a PROC CATALOG statement, you can continue to submit and execute statements or groups of statements without repeating the PROC CATALOG statement.
A set of procedure statements ending with a RUN statement is called a RUN group. The changes specified in a given group of statements take effect when a RUN statement is encountered.

How to End a PROC CATALOG Step

In the DATA step and most SAS procedures, a RUN statement is a step boundary and ends the step. A simple RUN statement does not, however, end an interactive procedure. The following list contains ways to terminate a PROC CATALOG step:
  • submit a QUIT statement
  • submit a RUN statement with the CANCEL option
  • submit another DATA or PROC statement
  • end your SAS session
Note: When you enter a QUIT, DATA, or PROC statement, any statements following the last RUN group execute before the CATALOG procedure terminates. If you enter a RUN statement with the CANCEL option, however, the remaining statements do not execute before the procedure ends.

Error Handling and RUN Groups

Error handling is based in part on the division of statements into RUN groups. If a syntax error is encountered, none of the statements in the current RUN group execute, and execution proceeds to the next RUN group.
For example, the following statements contain a misspelled DELETE statement:
   proc catalog catalog=misc entrytype=help;
      copy out=drink;
         select coffee tea;
      del juices;        /* INCORRECT!!! */
      exchange glass=plastic;
   run;
      change calstats=nutri;
   run;
Because the DELETE statement is incorrectly specified as DEL, no statements in that RUN group execute, except the PROC CATALOG statement itself. The CHANGE statement does execute, however, because it is in a different RUN group.
CAUTION:
Be careful when setting up batch jobs in which one RUN group's statements depend on the effects of a previous RUN group, especially when deleting and renaming entries.

Specifying an Entry Type

Four Ways to Supply an Entry Type

There is no default entry type, so if you do not supply one, PROC CATALOG generates an error. You can supply an entry type in one of four ways, as shown in the following table:
Supplying an Entry Type
Entry Type
Example
Entry name
delete
test1.program
       test1.log test2.log;
ET= in parentheses
delete
test1 (et=program);
ET= after a slash 1
delete test1 (et=program)
       test1 test2 / et=log;
ENTRYTYPE= without a slash 2
proc catalog catalog=mycat et=log;
     delete test1 test2;
1in a subordinate statement
2in the PROC CATALOG or the COPY statement
Note: All statements, except the CONTENTS statement, accept the ENTRYTYPE= (alias ET=) option.

Why Use the ENTRYTYPE= Option?

ENTRYTYPE= can save keystrokes when you are processing multiple entries of the same type.
To create a default for entry type for all statements in the current step, use ENTRYTYPE= in the PROC CATALOG statement. To set the default for only the current statement, use ENTRYTYPE= in a subordinate statement.
You can have many entries of one type and a few of other types. You can use ENTRYTYPE= to specify a default and then override that for individual entries with (ENTRYTYPE=) in parentheses after those entries.

Avoid a Common Error

You cannot specify the ENTRYTYPE= option in both the PROC CATALOG statement and a subordinate statement. For example, these statements generate an error and do not delete any entries because the ENTRYTYPE= specifications contradict each other:
/* THIS IS INCORRECT CODE. */
proc catalog cat=sample et=help;
   delete a b c / et=program;
run;

The ENTRYTYPE= Option

The ENTRYTYPE= option is available in every statement in the CATALOG procedure except CONTENTS.
ENTRYTYPE=etype
not in parentheses, sets a default entry type for the entire PROC step when used in the PROC CATALOG statement. In all other statements, this option sets a default entry type for the current statement. The alias is ET=. If you omit ENTRYTYPE=, PROC CATALOG processes all entries in the catalog.
Alias:ET=
Default:If you omit ENTRYTYPE=, PROC CATALOG processes all entries in the catalog.
Interactions:If you specify ENTRYTYPE= in the PROC CATALOG statement, do not specify either ENTRYTYPE= or (ENTRYTYPE=) in a subordinate statement.

(ENTRYTYPE=etype) in parentheses immediately following an entry name overrides ENTRYTYPE= in that same statement.

Tips:On all statements except the PROC CATALOG and COPY statements, this option follows a slash.

To process multiple entry types in a single PROC CATALOG step, use ENTRYTYPE= in a subordinate statement, not in the PROC CATALOG statement.

(ENTRYTYPE=etype)
in parentheses, identifies the type of the entry just preceding it.
Alias:(ET=)
Restriction:(ENTRYTYPE=etype) immediately following an entry name in a subordinate statement cannot override an ENTRYTYPE= option in the PROC CATALOG statement. It generates a syntax error.
Interaction:(ENTRYTYPE=etype) immediately following an entry name overrides ENTRYTYPE= in that same statement.
Tips:This form is useful mainly for specifying exceptions to an ENTRYTYPE= option used in a subordinate statement. The following statement deletes A.HELP, B.FORMAT, and C.HELP:
   delete a b (et=format) c / et=help;

For the CHANGE and EXCHANGE statements, specify (ENTRYTYPE=) in parentheses only once for each pair of names following the second name in the pair as shown in the following example:

   change old1=new1 (et=log)
          old1=new2 (et=help);

Catalog Concatenation

About Catalog Concatenation

There are two types of CATALOG concatenation. The first is specified by the LIBNAME statement and the second is specified by the global CATNAME statement. All statements and options that can be used on single (unconcatenated) catalogs can be used on catalog concatenations.

Restrictions

When you use the CATALOG procedure to copy concatenated catalogs and you use the NEW option, the following rules apply:
  1. If the input catalog is a concatenation and if the output catalog exists in any level of the input concatenation, the copy is not allowed.
  2. If the output catalog is a concatenation and if the input catalog exists in the first level of the output concatenation, the copy is not allowed.
For example, the following code demonstrates these two rules, and the copy fails:
LIBNAME first 'path-name1';
LIBNAME second 'path-name2';
/* create concat.x */
LIBNAME concat (first second);

/* fails rule #1 */
proc catalog c=concat.x;
   copy out=first.x new;
run;
quit;

/* fails rule #2 */
proc catalog c=first.x;
   copy out=concat.x new;
run;
quit;
In summary, the following table shows when copies are allowed. In the table, A and B are libraries, and each contains catalog X. Catalog C is an automatic concatenation of A and B, and catalog D is an automatic concatenation of B and A.
Input Catalog
Output Catalog
Copy Allowed?
C.X
B.X
No
C.X
D.X
No
D.X
C.X
No
A.X
A.X
No
A.X
B.X
Yes
B.X
A.X
Yes
C.X
A.X
No
B.X
C.X
Yes
A.X
C.X
No