Selected Autocall Macros Provided with SAS Software

Overview of Provided Autocall Macros

SAS supplies libraries of autocall macros to each SAS site. The libraries that you receive depend on the SAS products licensed at your site. You can use autocall macros without having to define or include them in your programs.
When SAS is installed, the autocall libraries are included in the value of the SASAUTOS system option in the system configuration file. The autocall macros are stored as individual members, each containing a macro definition. Each member has the same name as the macro definition that it contains.
Although the macros available in the autocall libraries supplied by SAS are working utility programs, you can also use them as models for your own routines. In addition, you can call them in macros that you write yourself.
To explore these macro definitions, browse the commented section at the beginning of each member. See the setting of SAS system option SASAUTOS, to find the location of the autocall libraries. To view the SASAUTOS value, use one of the following:
  • the OPTIONS command in the SAS windowing environment to open the OPTIONS window
  • the OPTIONS procedure
  • the VERBOSE system option
  • the OPLIST system option
For details about these options, see “SAS System Options,” in SAS System Options: Reference.
The following table lists selected autocall macros.
Selected Autocall Macros
Macro
Description
CMPRES and QCMPRES
Compresses multiple blanks and removes leading and trailing blanks. QCMPRES masks the result so special characters and mnemonic operators are treated as text instead of being interpreted by the macro facility.
COMPSTOR
Compiles macros and stores them in a catalog in a permanent SAS library.
DATATYP
Returns the data type of a value.
LEFT and QLEFT
Left-aligns an argument by removing leading blanks. QLEFT masks the result so special characters and mnemonic operators are treated as text instead of being interpreted by the macro facility.
SYSRC
Returns a value corresponding to an error condition.
TRIM and QTRIM
Trims trailing blanks. QTRIM masks the result so special characters and mnemonic operators are treated as text instead of being interpreted by the macro facility.
VERIFY
Returns the position of the first character unique to an expression.

Required System Options for Autocall Macros

To use autocall macros, you must set two SAS system options:
MAUTOSOURCE
activates the autocall facility. NOMAUTOSOURCE disables the autocall facility.
SASAUTOS=library-specification | (library-specification-1..., library-specification-n)
specifies the autocall library or libraries. For more information, see the SAS companion for your operating system.
If your site has installed the autocall libraries supplied by SAS and uses the standard configuration of SAS software supplied by SAS, you need only to ensure that the SAS system option MAUTOSOURCE is in effect to begin using the autocall macros.
Although the MAUTOLOCDISPLAY system option is not required, it displays the source location of the autocall macros in the SAS log when the autocall macro is invoked. For more information, see MAUTOLOCDISPLAY System Option.

Using Autocall Macros

To use an autocall macro, call it in your program with the statement %macro-name. The macro processor searches first in the WORK library for a compiled macro definition with that name. If the macro processor does not find a compiled macro and if the MAUTOSOURCE is in effect, the macro processor searches the libraries specified by the SASAUTOS option for a member with that name. When the macro processor finds the member, it does the following:
  1. compiles all of the source statements in that member, including all macro definitions
  2. executes any open code (macro statements or SAS source statements not within any macro definition) in that member
  3. executes the macro with the name that you invoked
After the macro is compiled, it is stored in the WORK.SASMACR catalog and is available for use in the SAS session without having to be recompiled.
You can also create your own autocall macros and store them in libraries for easy execution. For more information, see Storing and Reusing Macros.

Autocall Macros 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 contains definitions for the autocall macros that support DBCS.
Autocall Macros for DBCS
Autocall Macros
Description
%KLOWCASE and %QKLOWCAS
Changes the uppercase characters to lowercase.
%KTRIM and %QKTRIM
Trims the trailing blanks.
%KVERIFY
Returns the position of the first character unique to an expression.
For more information, see “Autocall Macros for NLS” in SAS National Language Support (NLS): Reference Guide.