Generally speaking from 99% of the examples I have seen it is to obfuscate and complicate code. SAS Base (also known as dataste) is the programming language - this should be the main part to learn and will cover 99% of all encountered needs. It contains all the data structures, functions and such like to manipulate and process data.
Macro language is an additional tool, used to generate Base SAS code. It does nothing on its own other than generate text. It has no data structures other than text, and it has no procedures/functions other than a couple of basic ones to generate text.
If you do need to write macro code - maybe for libraries or general code - then you should really be following Software Development Lifecycle mehodology - design the code in a documen first, create a teting plan, create a management plan etc. Then write some code. Don't fall into the "have to" use macro code, or over using it - Base SAS is where you can do almost every task imaginable.
I would also add, in the large majority of cases where macro is used, it is necessary for one of two reasons:
- Poor data structuring, some examples of which - holding similar data in many different datasets, using data as dataset names/variable names, using wide rather than long format (i.e. using a review type layout, rather than one designed for programming)
- Lack of understanding of Base SAS, something like using macro to loop over variables when arrays can do that, or generating lots of proc print/report statements rather than using by group processing.
... View more