Chapter Contents

Previous

Next
SAS Macro Language: Reference

Selected Autocall Macros Provided with SAS Software

SAS Institute 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 macro 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 Institute 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 on these options, refer to Chapter 16, "SAS System Options," in SAS Language: Reference, Version 6, First Edition.

Selected Autocall Macros lists selected autocall macros.

Selected Autocall Macros
Macro Description
CMPRES and QCMPRES compress multiple blanks and remove 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-align 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 trim 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
enables 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 Institute and uses the standard configuration of SAS software supplied by the Institute, you need only to ensure that the SAS system option MAUTOSOURCE is in effect to begin using the autocall macros.


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

  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 Chapter 9, "Storing and Reusing Macros."


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.