CHOOSEN Function

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

Category: Character
Restriction: I18N Level 2 functions are designed for use with SBCS, DBCS, and MBCS (UTF8).

Syntax

Required Arguments

index-expression

specifies a numeric constant, variable, or expression.

selection

specifies a numeric constant, variable, or expression. The value of this argument is returned by the CHOOSEN function.

Details

The CHOOSEN function uses the value of index-expression to select from the arguments that follow. For example, if index-expression is 3, CHOOSEN 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 CHOOSEN function is similar to the CHOOSEC function except that CHOOSEN returns a numeric value while CHOOSEC returns a character value.

Example

The following example shows how CHOOSEN chooses from a series of values:
data _null_;
   ItemNumber=choosen(5,100,50,3784,498,679);
   Rank=choosen(-2,1,2,3,4,5);
   Score=choosen(3,193,627,33,290,5);
   Value=choosen(-5,-37,82985,-991,3,1014,-325,3,54,-618);
   put ItemNumber= Rank= Score= Value=; 
run;
SAS writes the following line to the log:
ItemNumber=679 Rank=4 Score=33 Value=1014

See Also

Functions: