Autocall macros

From sasCommunity
Jump to: navigation, search
This is a work in progress. Please contribute to this article.

Autocall macros are pre-defined macros that can be used in SAS code without being defined or included in the program code before they are called. Users are able to pre-define their own autocall macros.

Setting up an autocall macro

The SAS code for an autocall macro needs to be saved in a self-contained text file with the name of the macro as the file name and a file extension of .sas. The file can be saved in a designated area of the SAS installation that already appears in the SASAUTOS option file paths, or the file path to the place where the autocall macro file is saved can be added to the file paths of the SASAUTOS option.

Note that on operating systems for which file names are case sensitive (e.g., Unix and Linux), the file names must be all lower case characters. For example, mymacro.sas. Such macros can still be referenced in your SAS code using mixed case (e.g., %myMacro).

A best practice is to always name your autocall macros with all lower case characters even on operating systems like Windows. That allows for the macros to work as is should the server environment change.

 
filename grp5mac 'c:\group5\macros';
filename prj5Amac 'c:\group5\prjA\macros';
options mautosource sasautos=(prj5amac, grp5mac, sasautos);

Library locations are specified with the SASAUTOS= option. You can specify more than one macro library in the SASAUTOS= option, and you can use filerefs (be sure to use FILENAME statements and not LIBNAME statements!) instead of the actual specification of the library location. The following example specifies three macro libraries:

Autocall macros provided by SAS

The following AutoCall Macros are provided by SAS.

  • %CMPRES autocall macro
  • %COMPSTOR autocall macro
  • %DATATYP autocall macro
  • %KVERIFY autocall macro
  • %LEFT autocall macro
  • %LOWCASE autocall macro
  • %QCMPRES autocall macro
  • %QLEFT autocall macro
  • %QLOWCASE autocall macro
  • %QTRIM autocall macro
  • %SYSRC autocall macro
  • %TRIM autocall macro
  • %VERIFY autocall macro

Further reading

SAS Documentation