In
Creating and Using Macro Programs,
you learned that you can submit a macro definition in order to compile
a macro. For example, when you submit the macro definition shown here,
the macro processor compiles the macro
Prtlast
:
%macro prtlast;
%if &syslast ne _NULL_ %then %do;
proc print data=&syslast(obs=5);
title "Listing of &syslast data set";
run;
%end;
%else
%put No data set has been created yet.;
%mend;
By default, the
Prtlast
macro
is stored in a temporary SAS catalog as Work.Sasmacr.Prtlast.Macro.
Macros that are stored in this temporary SAS catalog are known as
session-compiled macros. Once a macro has been compiled, it can be
invoked from a SAS program as shown here:
proc sort data=sasuser.courses out=bydays;
by days;
run;
%prtlast
Session-compiled macros
are available for execution during the SAS session in which they are
compiled. They are deleted at the end of the session. But suppose
you want to save your macros so that they are not deleted at the end
of the SAS session. The rest of this chapter looks at methods of storing
macros permanently.