Sentry Page Protection
Simple Macro [5-5]
Automatic Macro Variables Automatic macro variables are the built-in macro variables that can automate and enhance your program.
Example Copy and run the TRANSAC data set from the yellow box below.
The TRANSAC data set contains a list of transactions, agents and transaction amount:
&Sysdate, &Systime
Let's assume you have to run a summary report for the transaction amounts everyday. You could write a program that includes the date and time of the report in the title: Example Title1 "Transaction Report"; Title2 "May 8 at 12:10pm"; proc means data=transac N Mean STD; var amount; class agent; run; The program looks good. However, if you are going to run the program on a daily basis, you will have to manually change the date and time in the title statement: Example Title2 "May 8 at 12:10pm"; A better way to write the program is to use the automatic macro variables:
Sysdate and Systime are two built-in macro variables that contain the date and time of the current SAS session. Example Title1 "Transaction Report"; Title2 "&sysdate at &systime"; proc means data=transac N Mean STD; var amount; class agent; run; The macro variable sysdate and systime will be replaced by the date and time of the current SAS session, respectively. The date and time of the report will be automatically updated: You can find the full list of SAS automatic macro variable here. Exercise
Some other common automatic macro variables include:
Rerun the program above and add two footnotes to the program:
where xxx = operating system and yyy = SAS version. Need some help?
HINT SOLUTION proc means data=transac N Mean STD;
Fill out my online form.
|