To call an
autocall macro, the system options MAUTOSOURCE must be set and SASAUTOS
must be assigned. MAUTOSOURCE enables the autocall facility, and SASAUTOS
specifies the autocall libraries. For more information, see
MAUTOSOURCE System Option and
SASAUTOS= System Option.
Once you have set the
required options, calling an autocall macro is like calling a macro
that you have created in your current session. However, it is important
that you understand how the macro processor locates the called macro.
When you call a macro, the macro processor does the following tasks:
-
searches for a session compiled
macro definition
-
searches for a stored compiled
macro definition in the library specified by the SASMSTORE option,
if the MSTORED option is set
-
searches for a member in the autocall
libraries specified by the SASAUTOS option in the order in which they
are specified, if the MAUTOSOURCE option is set
-
searches the SASHELP library for
SAS production stored compiled macro definitions
When SAS finds a library
member in an autocall library with that macro name, the macro processor
does the following:
-
compiles all of the source statements
in that member, including any and all macro definitions, and stores
the result in the session catalog
-
executes any open code (macro statements
or SAS source statements not within any macro definition) in that
member
-
executes the macro with the name
that you invoked
Note: If an autocall library member
contains more than one macro, the macro processor compiles all of
the macros but executes only the macro with the name that you invoked.
Any open code statements
in the same autocall library member as a macro execute only the first
time you invoke the macro. When you invoke the macro later in the
same session, the compiled macro is executed, which contains only
the compiled macro definition and not the other code the autocall
macro source file might have contained.
It is not advisable
to change SASAUTOS during a SAS session. If you change the SASAUTOS=
specification in an ongoing SAS session, SAS will store the new specification
only until you invoke an uncompiled autocall macro and then will close
all opened libraries and open all the newly specified libraries that
it can open.