Because you can see the characters in the right side of the %IF condition and in the
%LET statement when you define the macro, you can use the %STR function to mask
them. Masking them once at compilation is more efficient than masking them at each
execution of ANALYZE.
To use the value of the macro variable OP as the operator in the %IF condition, you must
restore the meaning of the operator with the %UNQUOTE function.
What to Do When Automatic Unquoting Does Not Work
When the macro processor generates text from an item masked by a macro quoting
function, you can usually allow SAS to unquote the macro quoted items automatically.
For example, suppose you define a macro variable PRINTIT:
%let printit=%str(proc print; run;);
Then you use that macro variable in your program:
%put *** This code prints the data set: &printit ***;
When the macro processor generates the text from the macro variable, the items masked
by macro quoting functions are automatically unquoted, and the previously masked
semicolons work normally when they are passed to the rest of SAS.
In rare cases, masking text with a macro quoting function changes how the word scanner
tokenizes the text. (The word scanner and tokenization are discussed in Chapter 2, “SAS
Programs and Macro Processing,” on page 15 and Chapter 4, “Macro Processing,” on
page 39.) For example, a single or double quotation mark produced by resolution within
the %BQUOTE function becomes a separate token. The word scanner does not use it as
the boundary of a literal token in the input stack. If generated text that was once masked
by the %BQUOTE function looks correct but SAS does not accept it, you might need to
use the %UNQUOTE function to restore normal tokenization.
How Macro Quoting Works
When the macro processor masks a text string, it masks special characters and
mnemonics within the coding scheme, and prefixes and suffixes the string with a
hexadecimal character, called a delta character. The prefix character marks the
beginning of the string and also indicates what type of macro quoting is to be applied to
the string. The suffix character marks the end of the string. The prefix and suffix
characters preserve any leading and trailing blanks contained by the string. The
hexadecimal characters used to mask special characters and mnemonics and the
characters used for the prefix and suffix might vary and are not portable.
There are more hexadecimal combinations possible in each byte than are needed to
represent the symbols on a keyboard. Therefore, when a macro quoting function
recognizes an item to be masked, the macro processor uses a previously unused
hexadecimal combination for the prefix and suffix characters.
Macro functions, such as %EVAL and %SUBSTR, ignore the prefix and suffix
characters. Therefore, the prefix and suffix characters do not affect comparisons.
When the macro processor is finished with a macro quoted text string, it removes the
macro quoting-coded substitute characters and replaces them with the original
characters. The unmasked characters are passed on to the rest of the system. Sometimes
you might see a message about unmasking, as in the following example:
/* Turn on SYMBOLGEN so you can see the messages about unquoting. */
How Macro Quoting Works 99
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset