複数のステートメントまたはステートメントグループからその1つを実行します。
該当要素: | DATAステップ |
カテゴリ: | 制御 |
種類: | 実行 |
1つの値に評価される任意のSAS式を指定します。
参照項目 | select-expressionを指定する場合のwhen-expressionの評価 |
複合式などの任意のSAS式を指定します。SELECTでは、when-expressionを少なくとも1つ指定する必要があります。
ヒント | 複数のwhen-expressionsをカンマで区切ることは、論理演算子ORで区切ることに相当します。 |
when-expressionの使われ方は、select-expressionを指定するかどうかによって異なります。 | |
参照項目 | select-expressionを指定しない場合のwhen-expressionの評価 |
DOステートメント、SELECTステートメント、ヌルステートメントなどのSAS実行ステートメントを指定します。statement引数は必ず指定する必要があります。
select (a); when (1) x=x*10; when (2); when (3,4,5) x=x*100; otherwise; end;
select (payclass); when ('monthly') amt=salary; when ('hourly') do; amt=hrlywage*min(hrs,40); if hrs>40 then put 'CHECK TIMECARD'; end; /* end of do */ otherwise put 'PROBLEM OBSERVATION'; end; /* end of select */
select; when (mon in ('JUN', 'JUL', 'AUG') and temp>70) put 'SUMMER ' mon=; when (mon in ('MAR', 'APR', 'MAY')) put 'SPRING ' mon=; otherwise put 'FALL OR WINTER ' mon=; end;
/* INCORRECT usage to select value of 2 */ select (x); /* evaluates T/F and compares for */ /* equality with x */ when (x=2) put 'two'; end; /* correct usage */ select(x); /* compares 2 to x for equality */ when (2) put 'two'; end; /* correct usage */ select; /* compares 2 to x for equality */ when (x=2) put 'two'; end;
data test (keep=ItemNumber); set ItemList; select; %include NewItems; %include OldItems; otherwise put 'Item ' ItemNumber ' is not in the inventory.'; end; run;