0
indicates
that the expression is false, and a value of 1
or
any other numeric value indicates that the expression is true.
If you submit these
statements...
|
These messages are written
to the log...
|
---|---|
%put value=%eval(10 lt 2); |
value=0 |
%put value=10+2; %put value=%eval(10+2); |
value=10+2 value=12 |
%let counter=2; %let counter=%eval(&counter+1); %put counter=&counter; |
counter=3 |
%let numer=2; %let denom=8; %put value=%eval(&numer/&denom); |
value=0 |
%let numer=2; %let demon=8; %put value=%eval(&numer/&denom*&denom); %put value=%eval(&denom*&numer/&denom); |
value=0 value=2 |
%let real=2.4; %let int=8; %put value=%eval(&real+&int); |
value= |
real
variable
causes an error message to be written to the SAS log, as shown here.
1 %let real=2.4; 2 %let int=8; 3 %put value=%eval(&real+&int); ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: 2.4+8 value= |
General form, %SYSEVALF
function:
%SYSEVALF(expression<,
conversion-type>)
expression
is an arithmetic or
logical expression to evaluate.
conversion-type
converts the value
returned by %SYSEVALF to the type of value specified. Conversion-type
can be BOOLEAN, CEIL, FLOOR, or INTEGER.
|
%macro figureit(a,b); %let y=%sysevalf(&a+&b); %put The result with SYSEVALF is: &y; %put BOOLEAN conversion: %sysevalf(&a +&b, boolean); %put CEIL conversion: %sysevalf(&a +&b, ceil); %put FLOOR conversion: %sysevalf(&a +&b, floor); %put INTEGER conversion: %sysevalf(&a +&b, integer); %mend figureit; %figureit(100,1.59)
3.12.136.63