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
Functions Description
%KUPCASE and %QKUPCASE Converts values to uppercase.
For more information, see “Dictionary of Macro Functions for NLS” in SAS National
Language Support (NLS): Reference Guide.
Other Macro Functions
Seven other macro functions do not fit into the earlier categories, but they provide
important information. The following table lists these functions.
Table 12.8 Other Macro Functions
Function Description
%SYMEXIST Returns an indication as to whether the named macro variable
exists.
%SYMGLOBL Returns an indication as to whether the named macro variable is
global in scope.
%SYMLOCAL Returns an indication as to whether the named macro variable is
local in scope.
%SYSFUNC,
%QSYSFUNC
Execute SAS language functions or user-written functions within
the macro facility.
%SYSGET Returns the value of the specified host environment variable. For
more information, see the SAS Companion for your operating
environment.
%SYSPROD Reports whether a SAS software product is licensed at the site.
The %SYSFUNC and %QSYSFUNC functions enable the following:
most of the functions from Base SAS software
a function written with the SAS/TOOLKIT software
a function created using the FCMP procedure available to the macro facility
Consider the following examples:
• /* in a DATA step or SCL program */
dsid=open("Sasuser.Houses","i");
• /* in the macro facility */
%let dsid = %sysfunc(open(Sasuser.Houses,i));
For more information, see “%SYSFUNC and %QSYSFUNC Functions” on page 283.
166 Chapter 12 Macro Language Elements
..................Content has been hidden....................

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