CEXIST Function

Verifies the existence of a SAS catalog or SAS catalog entry.

Category: SAS File I/O

Syntax

CEXIST(entry<,'U'> )

Required Argument

entry

is a character constant, variable, or expression that specifies a SAS catalog, or the name of an entry in a catalog. If the entry value is a one- or two-level name, then it is assumed to be the name of a catalog. Use a three- or four-level name to test for the existence of an entry within a catalog.

Optional Argument

'U'

tests whether the catalog can be opened for updating.

Details

CEXIST returns 1 if the SAS catalog or catalog entry exists, or 0 if the SAS catalog or catalog entry does not exist.

Examples

Example 1: Verifying the Existence of an Entry in a Catalog

This example verifies the existence of the entry X.PROGRAM in LIB.CAT1:
data _null_;
   if cexist("lib.cat1.x.program") then
   put "Entry X.PROGRAM exists";
run;

Example 2: Determining if a Catalog Can Be Opened for Update

This example tests whether the catalog LIB.CAT1 exists and can be opened for update. If the catalog does not exist, a message is written to the SAS log. Note that in a macro statement you do not enclose character strings in quotation marks.
%if %sysfunc(cexist(lib.cat1,u)) %then
   %put The catalog LIB.CAT1 exists and can be opened for update.;
%else
   %put %sysfunc(sysmsg());

See Also

Functions: