Verifies the existence of a SAS catalog or SAS catalog entry
Category: SAS File I/O
CEXIST ( entry <,'U'>)
entry
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.
'U'
tests whether the catalog can be opened for updating.
CEXIST returns 1 if the SAS catalog or catalog entry exists, or 0 if the SAS catalog or catalog entry does not exist.
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;
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());
Function:
'EXIST Function' on page 514
Returns a character value that represents the results of choosing from a list of arguments
Category: Character
CHOOSEC ( index-expression , selection-1 < , selection-n >)
index-expression
specifies a numeric expression.
selection
specifies a character expression that is returned.
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.
The CHOOSEC function is similar to the CHOOSEN function except that CHOOSEC returns a character value while CHOOSEN returns a numeric value.
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
Functions:
'CHOOSEN Function' on page 436