Your macro just crashed and burned. So, what's the problem? Let’s take a look:
The text OR in the code above was misinterpreted as a logical operator. To correct this issue, use the %STR function to protect (disable the normal meaning of) special characters and mnemonics in constant text:
The macro below hasn't changed but correctly uses the %STR function, same as above. So, what’s the problem this time? Hint: The parameter value has changed; from NY (innocent) to OR (problem):
The %SUPERQ function in the code below is needed. Let’s examine why:
- %STR protects constant text that you type within your macro code.
- %SUPERQ protects the resolved value of a macro variable, during macro execution.
In the above example, the problem is not STATE. The problem is the resolved value of STATE (OR). Therefore, the %SUPERQ function is needed.
The argument to %SUPERQ is a single macro variable name, or an expression that resolves to a single macro variable name, without a leading ampersand (&).
%STR and %SUPERQ belong to a family of functions called quoting functions.
Don't let your macros crash and burn! To learn more about %STR, %SUPERQ, and other quoting functions, attend our SAS Macro Language 2: Advanced Techniques course.