Concepts: CATALOG Procedure


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. To terminate a PROC CATALOG step, you can

  • 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 Example 2 on page 172.

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. See Table 6.1 on page 165.

Table 6.1: Supplying an Entry Type

You can supply an entry type with

Example

the 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;  

[1] in a subordinate statement

[2] in 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.

If many entries are of one type, but a few are 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.

  • 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 on page 165.

  • Featured in: Example 1 on page 168

(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 .

  • Tip: 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; 
  • Tip: For the CHANGE and EXCHANGE statements, specify (ENTRYTYPE=) in parentheses only once for each pair of names following the second name in the pair. For example,

     change old1=new1(et=log)         old1=new2(et=help); 
  • See also: Specifying an Entry Type on page 165

  • Featured in: Example 1 on page 168 and Example 2 on page 172

Catalog Concatenation

The CATALOG procedure supports both implicit and explicit concatenation of catalogs. 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 implicit concatenation of A and B, and catalog D is an implicit 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




Base SAS 9.1.3 Procedures Guide (Vol. 1)
Base SAS 9.1 Procedures Guide, Volumes 1, 2, 3 and 4
ISBN: 1590472047
EAN: 2147483647
Year: 2004
Pages: 260

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net