Hi! My name is Jim. I’m a SAS instructor based in Irvine, CA. I spend a lot of time each year teaching students in CA and across the United States how to program in SAS and how to master the SAS macro facility.
In case you haven’t taken one of our SAS macro language courses yet, I want to share this tip. The SAS macro language will not make your computer or SAS run faster. However, if your job includes writing SAS code, the macro language can make you faster. For example, consider this simple SAS program:
proc print data=orion.customer (obs=8);
title "Customer List";
footnote "Created 10:24 Monday, 14FEB2012";
run;
The poor SAS user who uses the above program has to manually type the time, day, and date. Worse, what if this same user wants to run the same or similar program repeatedly at different times? What a nightmare -- this poor user must retype the time, day, and date again and again, and try not to make any mistakes!
Fortunately, there's an easier way. The answer: automatic macro variables! Note the references to three automatic macro variables in the footnote statement within the SAS program below:
proc print data=orion.customer;
title "Customer List";
footnote "Created &systime &sysday, &sysdate9";
run;
When you use the code above, you only have to type the macro variable references once. You’ll never type them again! The footnote will always reflect the correct time, date, and day. Be sure to use double-quotes, not single quotes, on the FOOTNOTE statement! One caution: The time, date, and day reflect the moment our SAS user launched his or her interactive SAS session; not the moment that he or she submitted the program.
To learn how to force automatic time, date and day updates and apply desired formats, consider attending our SAS Macro Language 1: Essentials course. What do you have to lose? Only time.
3 Comments
I know you mentioned that we have to use double quotes on the FOOTNOTE statement since
it uses macro variables. I would like to explicitly mention that double quotes are always needed whenever macro variables are used.
thanks from newbie jim to amazing prolific veteran charu!
great first post Jim and a terrific time saving tip!