Use the MINOPERATOR
system option or in the %MACRO statement if you want to use the
IN
(
#
) as operators
in expressions:
To use IN or # as operators
in expressions evaluated during the execution of a specific macro,
use the MINOPERATOR keyword on the definition of the macro:
%macro macroname / minoperator;
The macro IN operator
is similar to the DATA step IN operator, but not identical. The following
is a list of differences:
-
The macro IN operator cannot search
a numeric array.
-
The macro IN operator cannot search
a character array.
-
A colon (
:
) is not recognized as a shorthand notation to specify a range, such
as
1:10
means 1 through 10. Instead,
you use the following in a macro:
%eval(3 in 1 2 3 4 5 6 7 8 9 10);
-
-
Both operands must contain a value.
%put %eval(a IN a b c d); /*Both operands are present. */
If an operand contains a null value, an error is generated.
%put %eval( IN a b c d); /*Missing first operand. */
or
%put %eval(a IN); /*Missing second operand. */
Whether the first or second operand contains a null value, the same
error is written to the SAS log:
ERROR: Operand missing for IN operator in argument to %EVAL function.
The following example uses the macro IN operator
to search a character string:
%if &state in (NY NJ PA) %then %let ®ion = %eval(®ion + 1);