The %STR and %NRSTR
functions mask a character string during compilation of a macro or
macro language statement. They mask the following special characters
and mnemonic operators:
+ − * / < > = ¬ ^ ~ ; , # blank
AND OR NOT EQ NE LE LT GE GT IN
They also mask the following
characters when they occur in pairs and when they are not matched
and are marked by a preceding
%
In addition, %NRSTR
also masks the following characters:
Using %STR and %NSTR Arguments
|
|
Percent sign before
a quotation mark - for example, %' or %”,
|
Percent sign with quotation
mark
EXAMPLE: %let percent=%str(Jim%'s
office);
|
Percent sign before
a parenthesis - for example, %( or %)
|
EXAMPLE: %let x=%str(20%%);
|
Character string with
the comment symbols /* or -->
|
EXAMPLE: %str(/) %str(*) comment-text %str(*)%str(/)
|
%STR is most useful
for character strings that contain
-
a semicolon that should be treated
as text rather than as part of a macro program statement
-
blanks that are significant
-
a quotation mark or parenthesis
without a match
Putting the same argument
within nested %STR and %QUOTE functions is redundant. This example
shows an argument that is masked at macro compilation by the %STR
function and so remains masked at macro execution. Thus, in this example,
the %QUOTE function used here has no effect.
CAUTION:
Do not
use %STR to enclose other macro functions or macro invocations that
have a list of parameter values.
Because %STR masks
parentheses without a match, the macro processor does not recognize
the arguments of a function or the parameter values of a macro invocation.
For a description of
quoting in SAS macro language, see
Macro Quoting.
Note: The maximum level of nesting
for macro quoting functions is 10.