<?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: How to dynamically rename multiple variables in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-dynamically-rename-multiple-variables/m-p/182639#M3709</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not uis the variable label for the long names,&lt;/P&gt;&lt;P&gt;Keeps as easier coding for the programmer and having the longer name on all type of reports.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Nov 2014 06:36:39 GMT</pubDate>
    <dc:creator>jakarman</dc:creator>
    <dc:date>2014-11-24T06:36:39Z</dc:date>
    <item>
      <title>How to dynamically rename multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-dynamically-rename-multiple-variables/m-p/182635#M3705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;I tried to find by reading lot of stuff for renaming multiple variables dynamically but I couldn't find right solution for it.&lt;/P&gt;&lt;P&gt;In my dataset I have 159 variables named in short form (ex. AR_1) and I want to rename all the variables with there respective longforms. &lt;/P&gt;&lt;P&gt;Good news is I have a KEY dataset which is having short and long form names in vertical format for all of the (i.e. two columns short and long form for all 159 variables (which are observations in this dataset) ).&lt;/P&gt;&lt;P&gt;I tried using transpose and applying a user defined format(created using KEY dataset) but I want to know whether there is any way we can rename variables dynamically using some macro or some proc sql methods.(ex. in case if I dont have KEY dataset).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Harshad.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Nov 2014 17:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-dynamically-rename-multiple-variables/m-p/182635#M3705</guid>
      <dc:creator>HarshadMadhamshettiwar</dc:creator>
      <dc:date>2014-11-23T17:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically rename multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-dynamically-rename-multiple-variables/m-p/182636#M3706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Harshad&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Give this a try;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Tom&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data NameLookup;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; length OldName NewName $16;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; input OldName NewName;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; cards;&lt;BR /&gt;Name&amp;nbsp;&amp;nbsp;&amp;nbsp; XX_Name&lt;BR /&gt;Sex&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; YY_Sex&lt;BR /&gt;Age&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; II_Age&lt;BR /&gt;Height&amp;nbsp; AA_Height&lt;BR /&gt;Weight&amp;nbsp; BB_Weight&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set NameLookup end=LastRec;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if _n_ = 1 then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('proc sql; create table NewClass as select ');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if ^LastRec then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(Oldname || ' as ' || NewName || ',');&lt;BR /&gt;&amp;nbsp;&amp;nbsp; else call execute(Oldname || ' as ' || NewName);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if LastRec then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute(' from sashelp.class; quit;');&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Nov 2014 20:11:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-dynamically-rename-multiple-variables/m-p/182636#M3706</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2014-11-23T20:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically rename multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-dynamically-rename-multiple-variables/m-p/182637#M3707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Of course, if you just want to modify the original file, you could use &lt;A __default_attr="379045" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;'s approach to use proc datasets:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* create a dataset for testing */&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set NameLookup end=LastRec;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_ = 1 then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('proc datasets library=work nolist; modify have;');&lt;/P&gt;&lt;P&gt;&amp;nbsp; call execute('rename '|| Oldname || '=' || NewName ||';');&lt;/P&gt;&lt;P&gt;&amp;nbsp; if LastRec then call execute('quit;');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Nov 2014 21:49:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-dynamically-rename-multiple-variables/m-p/182637#M3707</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-11-23T21:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically rename multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-dynamically-rename-multiple-variables/m-p/182638#M3708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do your long form variables meet SAS variable naming restrictions, i.e. 32 characters or less, no spaces, and starts with character?&lt;/P&gt;&lt;P&gt;If they don't you'll want to set them as labels instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If so I usually do something like the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;select catx("=", old_name, new_name)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :rename_list separated by " "&lt;/P&gt;&lt;P&gt;from key_dataset;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc datasets library=work;&lt;/P&gt;&lt;P&gt;modify my_data;&lt;/P&gt;&lt;P&gt;rename &amp;amp;rename_list;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Nov 2014 00:03:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-dynamically-rename-multiple-variables/m-p/182638#M3708</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-11-24T00:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically rename multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-dynamically-rename-multiple-variables/m-p/182639#M3709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not uis the variable label for the long names,&lt;/P&gt;&lt;P&gt;Keeps as easier coding for the programmer and having the longer name on all type of reports.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Nov 2014 06:36:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-dynamically-rename-multiple-variables/m-p/182639#M3709</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-11-24T06:36:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically rename multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-dynamically-rename-multiple-variables/m-p/182640#M3710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;All answers are correct and exactly what I was seeking.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks everyone.&lt;/P&gt;&lt;P&gt;Cheers &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;...!!!&lt;/P&gt;&lt;P&gt;Harshad.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Nov 2014 09:20:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-dynamically-rename-multiple-variables/m-p/182640#M3710</guid>
      <dc:creator>HarshadMadhamshettiwar</dc:creator>
      <dc:date>2014-11-25T09:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically rename multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-dynamically-rename-multiple-variables/m-p/255203#M6939</link>
      <description>JaKarman,&lt;BR /&gt;sir yes indeed that is the ideal thing to do, but in my case users are closer to long forms...</description>
      <pubDate>Tue, 08 Mar 2016 09:50:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-dynamically-rename-multiple-variables/m-p/255203#M6939</guid>
      <dc:creator>HarshadMadhamshettiwar</dc:creator>
      <dc:date>2016-03-08T09:50:05Z</dc:date>
    </item>
  </channel>
</rss>

