Character Must Be Masked
' " ( ) If it might be unmatched No Arguments that might contain
quotation marks and parentheses
should be masked with a macro
quoting function so that the macro
facility interprets the single and
double quotation marks and
parentheses as text rather than
macro language symbols or
possibly unmatched quotation
marks or parentheses for the SAS
language. With %STR, %NRSTR,
%QUOTE, and %NRQUOTE,
unmatched quotation marks and
parentheses must be marked with
a % sign. You do not have to mark
unmatched symbols in the
arguments of %BQUOTE,
%NRBQUOTE, and %SUPERQ.
(Depends on what the
No %NRSTR, %NRBQUOTE, and
%NRQUOTE mask these patterns.
To use %SUPERQ with a macro
variable, omit the ampersand from
The macro facility allows you as much flexibility as possible in designing your macros.
You need to mask a special character with a macro quoting function only when the
macro processor would otherwise interpret the special character as part of the macro
language rather than as text. For example, in this statement that you must use a macro
quoting function to mask the first two semicolons to make them part of the text:
%let p=%str(proc print; run;);
However, in the macro PR, shown here, you do not need to use a macro quoting function
to mask the semicolons after PRINT and RUN:
%if &start=yes %then
%put proc print requested;
Because the macro processor does not expect a semicolon within the %DO group, the
semicolons after PRINT and RUN are not ambiguous, and they are interpreted as text.
Although it is not possible to give a series of rules that cover every situation, the
following sections describe how to use each macro quoting function. Table 7.6 on page
96 provides a summary of the various characters that might need masking and of which
macro quoting function is useful in each situation.
86 Chapter 7 • Macro Quoting