General form, %MACRO
statement, and %MEND statement:
%MACRO macro-name;
text
%MEND <macro-name>;
macro-name
names the macro. The
value of macro-name can be
any valid SAS name that is not a reserved word in the SAS macro facility.
text
can be
|
%macro prtlast; proc print data=&syslast (obs=5); title "Listing of &syslast data set"; run; %mend;
Prtlast
for execution
at a later time.
General form, MCOMPILENOTE=
option:
OPTIONS MCOMPILENOTE= NONE | NOAUTOCALL
| ALL;
NONE
is the default value,
which specifies that no notes are issued to the log.
NOAUTOCALL
specifies that a note
is issued to the log for completed macro compilations for all macros
except autocall macros.
ALL
specifies that a note
is issued to the log for all completed macro compilations.
|
options mcompilenote=all; %macro mymacro; %mend mymacro;
Prtlast
you
would call the macro as follows: %prtlast
Prtlast
prints
the most recently created data set. If Prtlast
has
been compiled, you can call it after each step in order to print each
data set. proc sort data=sasuser.courses out=courses; by course_code; run; %prtlast proc sort data=sasuser.schedule out=schedule; by begin_date; run; %prtlast proc sort data=sasuser.students out=students; by student_name; run; %prtlast
Prtlast
macro,
this might not be the best way to code this example. Since the Prtlast
macro
uses no conditional logic or macro programming statements and it makes
no decisions, this example does not illustrate the full power of a
macro program. In the rest of this chapter, you see examples of macro
programs that are more useful than this one.
Prtlast
macro
has been compiled and that it has been stored in the Work.Sasmacr
catalog.
Work.Sasmacr.Prtlast.Macro
.
%macro prtlast; proc print data=&syslast(obs=5); title "Listing of &syslast data set"; run; %mend;
proc print data=&syslast(obs=5); title "Listing of &syslast data set"; run;
Prtlast
macro.
%prtlast
is
submitted, assuming that the most recently created data set is Work.Practice.
37 %prtlast NOTE: Writing HTML Body file: sashtm3.htm NOTE: There were 5 observations read from the data set WORK.PRACTICE. NOTE: PROCEDURE PRINT used (Total process time): real time 0.04 seconds cpu time 0.03 seconds |