Mar 04 2005, 9am, Merck & Co., Inc., Rahway, NJ
Take an In-Depth Look at the %EVAL Function
Beilei Xu, Merck & Co., Inc., Rahway, NJ
Lei Zhang, Merck & Co., Inc., Rahway, NJ
%EVAL is a widely used yet frequently misunderstood SAS(r) macro language function due to its seemingly simple form. However, when its actual argument is a complex macro expression interlaced with special characters, mixed arithmetic and logical operators, or macro quotation functions, its usage and result become elusive and problematic.
In this paper, we aim to explore and demystify the intricate part of %EVAL. First, we explain the mechanism that the SAS macro processor uses to invoke %EVAL, and point out the subtle difference between the implicit and explicit uses of %EVAL calls. Then, we reveal a series of hidden rules that %EVAL uses to manipulate its actual macro argument embedded with different types of special characters. Examples are provided to illustrate those rules and exceptions on a case-by-case basis.
Beilei Xu is a Sr. Statistical Programmer at Merck & Co., Inc. She has six years of SAS programming experience.
Lei Zhang works as a senior statistical programmer at Merck & Co. Inc.. He is a SAS certified professional with 10+ years of SAS programming experience. He has written several technical papers for PharmaSUG, NESUG, and SUGI. His favorite topics are advanced SAS macro programming, data manipulation with SQL and Data/Proc steps, Java tools and SAS utilities for clinical study analysis and reporting.