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. */
options symbolgen;
/* Assign a value to EXAMPLE that contains several special */
/* characters and a mnemonic. */
%let example = %nrbquote( 1 + 1 = 3 Today's Test and More );
%put *&example*;
When this program is
submitted, the following appears in the SAS log:
SYMBOLGEN: Macro variable EXAMPLE resolves to 1 + 1 = 3 Today's
Test and More
SYMBOLGEN: Some characters in the above value which were subject
to macro quoting have been unquoted for printing.
* 1 + 1 = 3 Today's Test and More *
As you can see, the
leading and trailing blanks and special characters were retained in
the variable's value. While the macro processor was working with the
string, the string actually contained coded characters that were substituted
for the “real” characters. The substitute characters
included coded characters to represent the start and end of the string.
The leading and trailing blanks were preserved. Characters were also
substituted for the special characters
+
,
=
, and
'
,
and the mnemonic
AND
. When the macro finished
processing and the characters were passed to the rest of SAS, the
coding was removed and the real characters were replaced.