%macro greater(a, b);
%if &a gt &b
%then
%do;
%put a is greater than b;
%put b is less than a;
%end;
%else
%do;
%put a is less or equal than b;
%put b is greater or equal than a;
%end;
%mend greater;
%greater(10, 20);
%greater(20, 20);
%greater(30, 20);
The %if statement uses the %eval function to evaluate its condition.
Since %eval is only capable of integer arithmetic, an %if statement cannot handle something like %if 5.3 + 2.1 > 4.9:
%macro tq84_if;
%if 39 + 3 = 42
%then %put indeed, 39 + 3 is 42;
%else %put surprisingly, 39 + 3 is not 42;
/* The following %if statement does not work; it
will cause the following error message:
ERROR: A character operand was found in the %EVAL
function or %IF condition where a numeric
operand is required.
The condition was:
38.9 + 3.1 = 42
ERROR: The macro TQ84_IF will stop executing.*/
%if 38.9 + 3.1 = 42
%then %put indeed, 38.9 + 3.1 is 42;
%else %put surprisingly, 38.9 + 3.1 is not 42;
%mend tq84_if;