Previous Page | Next Page

Macro Language Elements

Selected Autocall Macros Provided with SAS Software


Overview of Provided Autocall Macros

SAS supplies libraries of autocall macros to each SAS site. The libraries 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 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 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:

For details about these options, see "SAS System Options," in SAS Language Reference: Dictionary.

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 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.

Previous Page | Next Page | Top of Page