Function Description
%SUPERQ Masks all special characters and mnemonic operators at macro
execution but prevents resolution of the value.
%UNQUOTE Unmasks all special characters and mnemonic operators for a
value.
Compilation Quoting Functions
%STR and %NRSTR mask special characters and mnemonic operators in values during
compilation of a macro definition or a macro language statement in open code. For
example, the %STR function prevents the following %LET statement from ending
prematurely. It keeps the semicolon in the PROC PRINT statement from being
interpreted as the semicolon for the %LET statement.
%let printit=%str(proc print; run;);
Execution of Macro Quoting Functions
%BQUOTE, %NRBQUOTE, %QUOTE, %NRQUOTE, and %SUPERQ mask special
characters and mnemonic operators in values during execution of a macro or a macro
language statement in open code. Except for %SUPERQ, these functions instruct the
macro processor to resolve a macro expression as far as possible and mask the result.
The other quoting functions issue warning messages for any macro variable references
or macro invocations that they cannot resolve. %SUPERQ protects the value of a macro
variable from any attempt at further resolution.
Of the quoting functions that resolve values during execution, %BQUOTE and
%NRBQUOTE are the most flexible. For example, the %BQUOTE function prevents
the following %IF statement from producing an error if the macro variable STATE
resolves to OR (for Oregon). Without %BQUOTE, the macro processor would interpret
the abbreviation for Oregon as the logical operator OR.
%if %bquote(&state)=nc %then %put North Carolina Dept. of
Revenue;
%SUPERQ fetches the value of a macro variable from the macro symbol table and
masks it immediately, preventing the macro processor from attempting to resolve any
part of the resolved value. For example, %SUPERQ prevents the following %LET
statement from producing an error when it resolves to a value with an ampersand, like
Smith&Jones. Without %SUPERQ, the macro processor would attempt to resolve
&Jones.
%let testvar=%superq(corpname);
/* No ampersand in argument to %superq. */
(%SUPERQ takes as its argument either a macro variable name without an ampersand or
a text expression that yields a macro variable name.)
Quotation Marks and Parentheses without a Match
Syntax errors result if the arguments of %STR, %NRSTR, %QUOTE, and %NRQUOTE
contain a quotation mark or parenthesis that does not have a match. To prevent these
164 Chapter 12 • Macro Language Elements