SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3

CEXIST Function

Verifies the existence of a SAS catalog or SAS catalog entry

Category: SAS File I/O

Syntax

CEXIST ( entry <,'U'>)

Arguments

entry

'U'

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

Function:

CHOOSEC Function

Returns a character value that represents the results of choosing from a list of arguments

Category: Character

Syntax

CHOOSEC ( index-expression , selection-1 < , selection-n >)

Arguments

index-expression

selection

Details

The CHOOSEC function uses the value of index-expression to select from the arguments that follow. For example, if index-expression is three, CHOOSEC returns the value of selection-3 . If the first argument is negative, the function counts backwards from the list of arguments, and returns that value.

Comparisons

The CHOOSEC function is similar to the CHOOSEN function except that CHOOSEC returns a character value while CHOOSEN returns a numeric value.

Examples

The following example shows how CHOOSEC chooses from a series of values:

data _null_; Fruit=choosec(1,'apple','orange','pear','fig'); Color=choosec(3,'red','blue','green','yellow'); Planet=choosec(2,'Mars','Mercury','Uranus'); Sport=choosec(-3,'soccer','baseball','gymnastics','skiing'); put Fruit= Color= Planet= Sport=; run;

SAS writes the following line to the log:

Fruit=apple Color=green Planet=Mercury Sport=baseball

See Also

Functions:

Категории