With SAS Global Forum less than two months away, I am busy putting the finishing touches on my papers. One of those papers is SAS Macro Programming for Beginners. Of all the conference papers I have written over the years, this is probably my favorite. Yet oddly, I have only presented this paper once at SGF and that was long ago. So I am pleased to have an opportunity to dust this paper off.
Don’t expect a lot of advanced macro tricks here. This paper is exactly what the title says: macro programming for beginners. It’s a crystal-clear presentation of the basic concepts you need to understand in order to be comfortable in the company of SAS macros. I can summarize the paper in two sentences that I call “Susan’s macro mottos.” Here they are:
Susan’s Macro Mottos
Remember: You are writing a program that writes a program.
This is the most important concept to keep in mind whenever you write or debug SAS macros. If you feel the least bit confused by a macro, repeating this motto can help you to see what is going on. I speak from personal experience here. This is my macro mantra.
To avoid mangling your macros, always write them one piece at a time.
First write your program in standard SAS code. When that is working and bug-free, then add your %MACRO and %MEND statements. When they are working, then add your parameters, if any, one at a time. If you make sure that each macro feature you add is working before you add another one, then debugging will be vastly simplified.
If you are lucky enough to attend SAS Global Forum and you want to catch this presentation, look for me in the Milano V-VI room Tuesday April 5, 2011, 10:30-11:20 am.
Click here to download the paper.