| Improving Program Efficiency with Macro Variables |
| Using Automatic Macro
Variables |
| Although the examples in this section show macro variable references
in a FOOTNOTE statement, macro variables can be referenced anywhere that
the information they supply is needed.
Remember, macro variables can appear anywhere in a SAS program, except within data lines. title 'Temporary Employees Hired in November';
footnote "Report Run on &sysday, &sysdate";
data hrd.tempnov;
set hrd.temp;
if month(begindate)=11;
run;
proc print data=hrd.tempnov;
run;
For example, this program uses the SYSDAY macro variable to execute a section of the program only on a specified day of the week. data hrd.temppay(drop=day);
set hrd.newtemp(keep=name payrate hours1 hours2);
total=hours1+hours2;
Day="&sysday";
if day='Friday' then
do;
gross=input(payrate,2.)*total;
tempfee=gross*.05;
end;
run;
proc print data=hrd.temppay;
run;
Note that the &SYSDAY reference appears in quotes. The quotes are needed
to correctly assign the text string that is contained in the macro variable
SYSDAY to the character variable |
![]() ![]() |
|
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.