<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Macro and data step variable renaming in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Macro-and-data-step-variable-renaming/m-p/249094#M56499</link>
    <description>&lt;P&gt;Please mark an accepted solution so that other folks can see that the problem is solved. That helps other people find solutions to their problems.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Feb 2016 23:24:21 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-02-09T23:24:21Z</dc:date>
    <item>
      <title>Macro and data step variable renaming</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-and-data-step-variable-renaming/m-p/249054#M56491</link>
      <description>&lt;P&gt;I need to rename&amp;nbsp;some data step variables to the values of a set of&amp;nbsp;macro variables.&amp;nbsp; 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.&amp;nbsp; The macro is used to create a group of data sets, one for each of the parameters that are passed to the macro with&amp;nbsp;an invocation of it.&amp;nbsp; 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.&amp;nbsp; In each of the datasets, these dataset variables need to be given the names of the unique macro variable contents&amp;nbsp;for that particular macro call.&amp;nbsp; The dataset variables need to be renamed because the datasets are merged together at the end of the program.&lt;/P&gt;&lt;P&gt;A simple rename type of&amp;nbsp;statement like the following would be nice:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rename dataset variable = contents of macro variable.&lt;/P&gt;&lt;P&gt;However, I can't make this work.&amp;nbsp; Is there a way to accomplish this task?&amp;nbsp; I use version 9.4.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 20:47:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-and-data-step-variable-renaming/m-p/249054#M56491</guid>
      <dc:creator>RWS</dc:creator>
      <dc:date>2016-02-09T20:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: Macro and data step variable renaming</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-and-data-step-variable-renaming/m-p/249056#M56492</link>
      <description>Not quite following.  Could you show a small bit of sample data, and how you would want to call the macro to rename the variables?  Can you show what you have tried?  Would a macro that allows you to rename a list of variables to add a prefix or suffix help?</description>
      <pubDate>Tue, 09 Feb 2016 20:54:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-and-data-step-variable-renaming/m-p/249056#M56492</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2016-02-09T20:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: Macro and data step variable renaming</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-and-data-step-variable-renaming/m-p/249063#M56495</link>
      <description>&lt;P&gt;There are several ways to do this depending on how persistent your macro variables are.&lt;/P&gt;
&lt;P&gt;One way would be to rename them using proc datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc datasets library=lib ;&amp;nbsp; /* put the name of the library where&amp;nbsp;the data set you want to modify exists*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; modify yourdatasetname;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rename currentvar1 = &amp;amp;macrovar1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;currentvar2 = &amp;amp;macrovar2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;currentvar3 = &amp;amp;macrovar3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another if the macro variables are persistent enough would be to have a rename in the data set options when actually combining the sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data big;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inputset1 (rename=(var1=&amp;amp;rename1_1 var2=&amp;amp;rename2_1)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inputset2 (rename=(var1=&amp;amp;rename1_2 var2=&amp;amp;rename2_2)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inputset3 (rename=(var1=&amp;amp;rename1_3 var2=&amp;amp;rename2_3)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 21:05:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-and-data-step-variable-renaming/m-p/249063#M56495</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-09T21:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: Macro and data step variable renaming</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-and-data-step-variable-renaming/m-p/249081#M56497</link>
      <description>&lt;P&gt;Your first suggested method for solving the problem works!&amp;nbsp; Thanks a lot.&amp;nbsp; It's a big help.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 22:22:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-and-data-step-variable-renaming/m-p/249081#M56497</guid>
      <dc:creator>RWS</dc:creator>
      <dc:date>2016-02-09T22:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: Macro and data step variable renaming</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-and-data-step-variable-renaming/m-p/249083#M56498</link>
      <description>&lt;P&gt;The other person who responded had a suggested solution that works.&amp;nbsp; Thanks anyway.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 22:25:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-and-data-step-variable-renaming/m-p/249083#M56498</guid>
      <dc:creator>RWS</dc:creator>
      <dc:date>2016-02-09T22:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: Macro and data step variable renaming</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Macro-and-data-step-variable-renaming/m-p/249094#M56499</link>
      <description>&lt;P&gt;Please mark an accepted solution so that other folks can see that the problem is solved. That helps other people find solutions to their problems.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 23:24:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Macro-and-data-step-variable-renaming/m-p/249094#M56499</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-09T23:24:21Z</dc:date>
    </item>
  </channel>
</rss>

