Just to add a bit to Paige's correct answer... The %IF statement uses the %EVAL function to evaluate expressions. %EVAL can evaluate both numeric expressions and character expressions. But there is no way for you to tell %EVAL to do a numeric comparison or a character comparison. So %EVAL needs to look at the expression, and decide whether to do a numeric comparison or character comparison. It has simple rules to make this decision, basically, if the operands are all numbers, do a numeric comparison, else do a character comparison. Unfortunately, %EVAL does not know that a decimal point can be part of a number. So if you do:
%put %eval(2 > 10.0) ; %*True- character comparison;
you get 1 (true), because it's doing a character (alphabetical) comparison. It's the equivalent of:
data _null_;
if "2">"10.0" then put "2 is greater than 10.0" ;
run;
%SYSEVALF also has to decide whether to do a numeric or character expression, but it knows that a decimal point can be part of a number. So
%put %sysevalf(2>10.0) ; %*False - numeric comparison;
returns false because it does a numeric comparison. If you add an extra dot to 10.0, %sysevalf sees that 10.0. is not a number, and changes to a character comparison
%put %sysevalf(2>10.0.) ; %*True- character comparison;
... View more