I need to rename some data step variables to the values of a set of macro variables. The macro variables have new, different values each time the macro is invoked because a different parameter is passed to the macro with each call. The macro is used to create a group of data sets, one for each of the parameters that are passed to the macro with an invocation of it. Each of these datasets has a common set of dataset variables -- that is, they are common across all of the datasets created because they are created from a single, large dataset. In each of the datasets, these dataset variables need to be given the names of the unique macro variable contents for that particular macro call. The dataset variables need to be renamed because the datasets are merged together at the end of the program.
A simple rename type of statement like the following would be nice:
rename dataset variable = contents of macro variable.
However, I can't make this work. Is there a way to accomplish this task? I use version 9.4.
There are several ways to do this depending on how persistent your macro variables are.
One way would be to rename them using proc datasets.
Proc datasets library=lib ; /* put the name of the library where the data set you want to modify exists*/
rename currentvar1 = ¯ovar1
currentvar2 = ¯ovar2
currentvar3 = ¯ovar3
Another if the macro variables are persistent enough would be to have a rename in the data set options when actually combining the sets.
inputset1 (rename=(var1=&rename1_1 var2=&rename2_1)
inputset2 (rename=(var1=&rename1_2 var2=&rename2_2)
inputset3 (rename=(var1=&rename1_3 var2=&rename2_3)
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.