The CATALOG Procedure |
Interactive Processing with RUN Groups |
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.
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.
See Displaying Contents, Changing Names, and Changing a Description.
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.
Specifying 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:
Entry Type | Example | |
---|---|---|
the entry name |
delete test1.program test1.log test2.log; |
|
ET= in parentheses |
delete test1 (et=program); |
|
ET= after a slash (table note 1) |
delete test1 (et=program) test1 test2 / et=log; |
|
ENTRYTYPE= without a slash (table note 2) |
proc catalog catalog=mycat et=log; delete test1 test2; |
TABLE NOTE 1: in a subordinate statement
TABLE NOTE 2: in the PROC CATALOG or the COPY statement
Note: All statements, except the CONTENTS statement, accept the ENTRYTYPE= (alias ET=) 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.
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 is available in every statement in the CATALOG procedure except CONTENTS.
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.
Alias: | ET= |
Default: | If you omit ENTRYTYPE=, PROC CATALOG processes all entries in the catalog. |
Interaction: | If you specify ENTRYTYPE= in the PROC CATALOG statement, do not specify either ENTRYTYPE= or (ENTRYTYPE=) in a subordinate statement. |
Interaction: | (ENTRYTYPE=etype) in parentheses immediately following an entry name overrides ENTRYTYPE= in that same statement. |
Tip: | On all statements except the PROC CATALOG and COPY statements, this option follows a slash. |
Tip: | To process multiple entry types in a single PROC CATALOG step, use ENTRYTYPE= in a subordinate statement, not in the PROC CATALOG statement. |
See also: | Specifying an Entry Type. |
Featured in: | Copying, Deleting, and Moving Catalog Entries from Multiple Catalogs |
in parentheses, identifies the type of the entry just preceding it.
See also: | Specifying an Entry Type |
Featured in: | Copying, Deleting, and Moving Catalog Entries from Multiple Catalogs and Displaying Contents, Changing Names, and Changing a Description |
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.
When you use the CATALOG procedure to copy concatenated catalogs and you use the NEW option, the following rules apply:
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.
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 |
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.