These conversion types modify the value returned by %SYSEVALF so that it can be
used in other macro expressions that require integer or Boolean values.
CAUTION:
Specify a conversion type for the %SYSEVALF function. If you use the
%SYSEVALF function in macro expressions or assign its results to macro variables
that are used in other macro expressions, then errors or unexpected results might
occur if the %SYSEVALF function returns missing or floating-point values. To
prevent errors, specify a conversion type that returns a value compatible with other
macro expressions. For more information about using conversion types, see
“%SYSEVALF Function” on page 281.
How the Macro Processor Evaluates Logical
Expressions
Comparing Numeric Operands in Logical Expressions
A logical, or Boolean, expression returns a value that is evaluated as true or false. In the
macro language, any numeric value other than 0 is true and a value of 0 is false.
When the macro processor evaluates logical expressions that contain operands that
represent numbers, it converts the characters temporarily to numeric values. To illustrate
how the macro processor evaluates logical expressions with numeric operands, consider
the following macro definition:
%macro compnum(first,second);
%if &first>&second %then %put &first is greater than &second;
%else %if &first=&second %then %put &first equals &second;
%else %put &first is less than &second;
%mend compnum;
Invoke the COMPNUM macro with these values:
%compnum(1,2)
%compnum(-1,0)
The following results are displayed in the log:
1 is less than 2
-1 is less than 0
The results show that the operands in the logical expressions were evaluated as numeric
values.
Comparing Floating-Point or Missing Values
You must use the %SYSEVALF function to evaluate logical expressions containing
floating-point or missing values. To illustrate comparisons with floating-point and
missing values, consider the following macro that compares parameters passed to it with
the %SYSEVALF function and places the result in the log:
%macro compflt(first,second);
%if %sysevalf(&first>&second) %then %put &first is greater than
&second;
%else %if %sysevalf(&first=&second) %then %put &first equals
78 Chapter 6 • Macro Expressions