SAS Component Language Dictionary |
Category: | Control Flow |
Comparisons: | SAS Statement with limitations in SCL |
Syntax | |
Differences in SELECT Statement Execution | |
Example |
Syntax |
SELECT<(select-expression)>;
|
END; |
is an expression that evaluates to a single value. This argument is optional. If used, select-expression must be in parentheses.
is a constant or an expression that evaluates to a single value.
are one or more executable SAS statements, including DO, SELECT, and null statements. When used in a WHEN statement, a null statement causes SAS to recognize a condition as true without taking further action. In OTHERWISE statements, null statements prevent SAS from issuing an error message when all WHEN conditions are false.
Differences in SELECT Statement Execution |
For SELECT groups in SCL, WHEN statements of the form WHEN(a1, a2, a3) are not supported. However, the following forms are supported:
OTHERWISE is an optional statement. If OTHERWISE is omitted, and if no WHEN conditions are met, the program halts.
Each WHEN statement implies a DO group of all statements until the next WHEN or OTHERWISE statement. Therefore, the following program is valid:
select(x); when(1) call display('a'); ...optionally, more SCL statements... when(2) call display('b'); ...optionally, more SCL statements... otherwise call display('bad'); ...optionally, more SCL statements... end;
For details about the SELECT statement in the Base SAS language, see SAS Language Reference: Dictionary.
Example |
This example shows how to use expressions with the SELECT statement:
select; when(x=1) put 'one'; when(2<x<5) put 'between two and five'; when(x>5 or x<0) put 'other'; end;
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.