Chapter Contents |
Previous |
Next |
SAS Component Language: Reference |
Expressions are used for calculating and assigning new values, for conditional processing, and for transforming variables. These examples show SAS expressions:
SCL expressions can resolve to numeric, character, or Boolean values. In addition, a numeric expression that contains no logical operators can serve as a Boolean expression.
Boolean Numeric Expressions |
A numeric expression can be simply a numeric constant, as follows:
if 5 then do;The numeric value returned by a function is also a valid numeric expression:
if index(address,'Avenue') then do;
Using Functions in Expressions |
rc=fetch(dsid); /* The return code -1 means the */ /* end of the file was reached. */ if (rc=-1) then do; ...SCL statements to handle the end-of-file condition... end;
To eliminate the variable for the return code, you can use the function directly in the IF statement's expression, as shown in the following example:
if (fetch(dsid)=-1) then do; ...SCL statements to handle the end-of-file condition... end;
In this case, the FETCH function is executed, and then the IF expression evaluates the return code to determine whether to perform the conditional action.
As long as you do not need the value of the function's return code for any other processing, the latter form is more efficient because it eliminates the unnecessary variable assignment.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.