Functions and CALL Routines |
Returns a numeric value that represents the results of choosing
from a list of arguments.
CHOOSEN (index-expression, selection-1
<,...selection-n>)
|
-
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.
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.
The CHOOSEN function is similar to the
CHOOSEC function except that CHOOSEN returns a numeric value while CHOOSEC
returns a character value.
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
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.