CEXIST Function


CEXIST Function

Verifies the existence of a SAS catalog or SAS catalog entry

Category: SAS File I/O

Syntax

CEXIST ( entry <,'U'>)

Arguments

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.

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:

  • 'EXIST Function' on page 514

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

  • specifies a numeric expression.

selection

  • specifies a character expression that is returned.

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:

  • 'CHOOSEN Function' on page 436




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

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