Chapter 9
Storing and Reusing Macros
Storing and Reusing Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Saving Macros in an Autocall Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Overview of an Autocall Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Using Directories as Autocall Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Using SAS Catalogs as Autocall Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Calling an Autocall Macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Saving Macros Using the Stored Compiled Macro Facility . . . . . . . . . . . . . . . . . . 119
Overview of the Stored Compiled Macro Facility . . . . . . . . . . . . . . . . . . . . . . . . . 119
Compiling and Storing a Macro Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Storing Autocall Macros Supplied by SAS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Calling a Stored Compiled Macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Storing and Reusing Macros
When you submit a macro definition, by default, the macro processor compiles and
stores the macro in a SAS catalog in the Work library. These macros, referred to as
session compiled macros, exist only during the current SAS session. To save frequently
used macros between sessions, you can use either the autocall macro facility or the
stored compiled macro facility.
The autocall macro facility stores the source for SAS macros in a collection of external
files called an autocall library. The autocall facility is useful when you want to create a
pool of easily maintained macros in a location that can be accessed by different
applications and users. Autocall libraries can be concatenated together. The primary
disadvantage of the autocall facility is that the first time an autocall macro is called in a
session, the macro processor compiles it. This compilation is overhead that you can
avoid by using the stored compiled macro facility.
The stored compiled macro facility stores compiled macros in a SAS catalog in a SAS
library that you specify. By using stored compiled macros, you might save macro
compilation time in your production-level jobs. However, because these stored macros
are compiled, you must save and maintain the source for the macro definitions in a
different location.
The autocall facility and the stored compiled macro facility each offer advantages. Here
are some of the factors that determine how you choose to save a macro definition:
how often you use a macro
115
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset