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


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


Changing Data Set Variables into Macro Variables

From sasCommunity
Jump to: navigation, search

Paper 050-2007

Changing Data Set Variables into Macro Variables

William C. Murphy

Howard M. Proskin and Associates, Inc., Rochester, NY

Abstract

For reusing code, macro variables are an indispensable part of the SAS® system. You can create multi-use programs in which titling, subsetting, and even analysis variables can be controlled by changing the values of macro variables. To create a few macro variables, the %LET statement works extremely well. But if you want to automate the production of macro variables, DATA steps with the CALL SYMPUT statement or PROC SQL provide a better method. If a large number of macro variables need to be created from data set variables, however, even these solutions many require a great deal of typing. Furthermore, if the number of macro variables created for each data set variable and observation is extremely large, the memory demands on the system can be huge. The SAS system however, provides an elegant way to overcome these problems with the CALL SET routine. The macro version of this routine, %SYSCALL SET provides a simple way to convert data set variables into the equivalent macro variables with few lines of code. Furthermore, the routine allows you to convert and process one observation of data set variables at a time, thus saving on system memory usage. The %SYSCALL SET routine is the ideal solution for changing data set variables into macro variables.

Online resources