Dear SAS users and excellent blog readers, this week's sort of randomly selected tip comes from esteemed SAS author Art Carpenter. Many of you are probably familiar with Art's work and may have had the pleasure of hearing him speak at a user group conference. He's a great communicator and his SAS knowledge translates easily to the page.
The following excerpt is from SAS Press author Art Carpenter's book Carpenter's Complete Guide to the SAS Macro Language, Second Edition. Copyright © 2004, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED. (please note that results may vary depending on your version of SAS software)
Elements of a dynamic program
While not always present, there are certain elements that tend to be in macros that dynamically build code. These elements include the following:
- Macro variable values are based on an information source like a SAS data set.
- The SYMPUT routine or the SQL INTO: is used to build the macro variables.
- Macro arrays of the form &&VAR&I are common.
- The number of array elements is saved in a macro variable.
- %DO loops are used to step through the macro arrays.
As you learn to write this type of macro, watch for these elements and notice how they fit together. The pattern formed by these elements is repeated over and over again in the examples in this book.
Visit Art Carpenter's author page to read a free chapter from this book, to learn about his other titles, and to view reviews, interviews, and more.