Skip to main content
Article thumbnail
Location of Repository

Macros and Conventional Macro Variables: Effective Tools for Customizing Tabular Output in SAS ® ODS

By Perry Watts Stakana Analytics


While it is understood that macro variables are referenced in ODS by using MVAR and NMVAR statements, macro programs continue to play a vital role in ODS. To back up this claim, the TABLETEMPLATE macro that generates a customized table in ODS is reviewed in depth. Looping in the macro eliminates the need for hard coding, and multiple ampersand macro variables (&&f&i) provide the only viable means for inserting data dependent text strings into a table. Pre and Post macro versions of the code are presented to emphasize the role played by macros in ODS. PROBLEM DEFINITION To generalize PROC TEMPLATE table definitions, it is recommended that DYNAMIC variables reference structural components such as headers or footers and that MVAR and NMVAR be reserved for constants that can change each time a compiled template is called in a DATA step. However, what if the macro variables you need to define come from the set of unique values in a column from the input data? Furthermore, what if you need a different outcome in a PROC TEMPLATE CELLSTYLE-AS statement for each unique value in the column? In this situation, a reliable table definition requires the assistance of a full-fledged macro with looping capabilities. What the paper describes is an application where an ODS table definition is nested inside the macro TABLETEMPLATE. The table definition uses MVAR and DYNAMIC variables in addition to conventional macro variables with multiple ampersands for managing the CELLSTYLE-AS statement

Year: 2013
OAI identifier: oai:CiteSeerX.psu:
Provided by: CiteSeerX
Download PDF:
Sorry, we are unable to provide the full text but you may find it at the following location(s):
  • (external link)
  • (external link)
  • Suggested articles

    To submit an update or takedown request for this paper, please submit an Update/Correction/Removal Request.