Deciding How Much Text to Mask with a Macro
Quoting Function
In each of the following statements, the macro processor treats the masked semicolons as
text:
%let p=%str(proc print; run;);
%let p=proc %str(print;) %str(run;);
%let p=proc print%str(;) run%str(;);
The value of P is the same in each case:
proc print; run;
The results of the three %LET statements are the same because when you mask text with
a macro quoting function, the macro processor quotes only the items that the function
recognizes. Other text enclosed in the function remains unchanged. Therefore, the third
%LET statement is the minimalist approach to macro quoting. However, masking large
blocks of text with a macro quoting function is harmless and actually results in code that
is much easier to read (such as the first %LET statement).
%SUPERQ Function
Using %SUPERQ
The %SUPERQ function locates the macro variable named in its argument and quotes
the value of that macro variable without permitting any resolution to occur. It masks all
items that might require macro quoting at macro execution. Because %SUPERQ does
not attempt any resolution of its argument, the macro processor does not issue any
warning messages that a macro variable reference or a macro invocation has not been
resolved. Therefore, even when the %NRBQUOTE function enables the program to
work correctly, you can use the %SUPERQ function to eliminate unwanted warning
messages from the SAS log. %SUPERQ takes as its argument either a macro variable
name without an ampersand or a text expression that yields a macro variable name.
%SUPERQ retrieves the value of a macro variable from the macro symbol table and
quotes it immediately, preventing the macro processor from making any attempt to
resolve anything that might occur in the resolved value. For example, if the macro
variable CORPNAME resolves to Smith&Jones, using %SUPERQ prevents the macro
processor from attempting to further resolve
&Jones. This %LET statement
successfully assigns the value Smith&Jones to TESTVAR:
%let testvar=%superq(corpname);
Examples Using %SUPERQ
This example shows how the %SUPERQ function affects two macro invocations, one
for a macro that has been defined and one for an undefined macro:
%window ask
#5 @5 'Enter two values:'
#5 @24 val 15 attr=underline;
%SUPERQ Function 93