errors, mark these quotation marks and parentheses by preceding them with a percent
sign. For example, write the following to store the value 345)in macro variable B:
%let b=%str(345%));
If an argument of %STR, %NRSTR, %QUOTE, or %NRQUOTE contains a percent
sign that precedes a quotation mark or parenthesis, use two percent signs (%%) to
specify that the argument's percent sign does not mark the quotation mark or parenthesis.
For example, write the following to store the value TITLE "20%";in macro variable P:
%let p=%str(TITLE "20%%";);
If the argument for one of these functions contains a character string with the comment
symbols /* and -->, use a %STR function with each character. For example, consider
these statements:
%let instruct=Comments can start with %str(/)%str(*).;
%put &instruct;
They write the following line to the SAS log:
Comments can start with /*
Note: Unexpected results can occur if the comment symbols are not quoted with a
quoting function.
For more information about macro quoting, see “Macro Quoting” on page 82.
Macro Functions for Double-Byte Character Set (DBCS)
Because East Asian languages have thousands of characters, double (two) bytes of
information are needed to represent each character. Each East Asian language usually
has more than one DBCS encoding system. SAS processes the DBCS encoding
information that is unique for the major East Asian languages. The following table
defines the macro functions that support DBCS.
Table 12.7 Macro Functions for DBCS
Functions Description
%KCMPRES Compresses multiple blanks and removes
leading and trailing blanks.
%KINDEX Returns the position of the first character of a
string.
%KLEFT and %QKLEFT Left-aligns an argument by removing leading
blanks.
%KLENGTH Returns the length of a string.
%KSCAN and %QKSCAN Searches for a word that is specified by its
position in a string.
%KSUBSTR and %QKSUBSTR %KSUBSTR and %QKSUBSTR produces a
substring of a character string.
Macro Functions 165