Case Study: Westat achieves function-style macros that run DATA/PROC steps with SAS

A SAS Case Study

Preview of the Westat Case Study

Westat creates function-style flexibility in a macro

Westat senior VP Mike Rhoads tackled a common SAS programming challenge: users wanted function-style macros that could be embedded inside SAS statements (via %SYSFUNC) but still perform full DATA or PROC steps behind the scenes—a capability that traditional function-style macros lacked. A practical example was expanding complex user-specified variable lists into explicit variable names, which normally requires PROC TRANSPOSE and PROC SQL and thus couldn’t be done inside a simple macro expression.

Rhoads’ “Macro Function Sandwich” solves this by layering an outer user-facing macro, a user-written PROC FCMP function (called with %SYSFUNC) and an inner macro invoked via RUN_MACRO. The inner macro runs the necessary DATA/PROC steps (e.g., PROC TRANSPOSE + PROC SQL to expand variable lists) and returns text to the FCMP function and then to the outer macro. The result: function-style macros can now leverage the full power of SAS procedures, removing previous restrictions and enabling more flexible, maintainable solutions for missing language features.


Open case study document...

Westat

Mike Rhoads

Vice President


SAS

305 Case Studies