As the first step in the decommissioning of the site has been converted to read-only mode.

Here are some tips for How to share your SAS knowledge with your professional network.

A Tutorial on the SAS® Macro Language

From sasCommunity
Jump to: navigation, search
John J. Cohen
AstraZeneca LP


The SAS Macro language is another language that rests on top of regular SAS code. If used properly, it can make programming easier and more fun. However, not every program is improved by using macros. Furthermore, it is another language syntax to learn, and can create problems in debugging programs that are even more entertaining than those offered by regular SAS.

We will discuss using macros as code generators, saving repetitive and tedious effort, for passing parameters through a program to avoid hard coding values, and to pass code fragments, thereby making certain tasks easier than using regular SAS alone. Macros facilitate conditional execution and can be used to create program modules that can be standardized and re-used throughout your organization. Finally, macros can help us create interactive systems in the absence of SAS/AF.

When we are done, you will know the difference between a macro, a macro variable, a macro statement, and a macro function. We will introduce interaction between macros and regular SAS language, offer tips on debugging macros, and discuss SAS macro options.

Online materials

View the .pdf of this paper.