<?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: Replacing the variable names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replacing-the-variable-names/m-p/206478#M267147</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since there's no discernable pattern you'll need to manually use rename statements. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rename ar1=CA35543 ar2=CH5783 etc;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Mar 2015 01:22:11 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-03-20T01:22:11Z</dc:date>
    <item>
      <title>Replacing the variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-the-variable-names/m-p/206477#M267146</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;The sample of my original dataset looks as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ar1&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; ar2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbs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.077040716&lt;/TD&gt;&lt;TD&gt;0.2230172601&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;05/01/2004&lt;/TD&gt;&lt;TD&gt;-0.072398762&lt;/TD&gt;&lt;TD&gt;-0.064743906&lt;/TD&gt;&lt;TD&gt;-0.026989673&lt;/TD&gt;&lt;TD&gt;-0.127645586&lt;/TD&gt;&lt;TD&gt;0.0311527312&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;06/01/2004&lt;/TD&gt;&lt;TD&gt;0.0056040872&lt;/TD&gt;&lt;TD&gt;0.1373077807&lt;/TD&gt;&lt;TD&gt;0.0122890855&lt;/TD&gt;&lt;TD&gt;0.0957376211&lt;/TD&gt;&lt;TD&gt;-0.025696325&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;07/01/2004&lt;/TD&gt;&lt;TD&gt;0.0310395172&lt;/TD&gt;&lt;TD&gt;0.036282484&lt;/TD&gt;&lt;TD&gt;-0.00868609&lt;/TD&gt;&lt;TD&gt;0.0554872928&lt;/TD&gt;&lt;TD&gt;-0.075945777&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;08/01/2004&lt;/TD&gt;&lt;TD&gt;-0.021351471&lt;/TD&gt;&lt;TD&gt;0.0808676035&lt;/TD&gt;&lt;TD&gt;-0.032316476&lt;/TD&gt;&lt;TD&gt;0.0035982172&lt;/TD&gt;&lt;TD&gt;-0.042734186&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I want to change the variable names. The new variables names will be &lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;CA45245E1097&lt;/TD&gt;&lt;TD&gt;CH0018666781&lt;/TD&gt;&lt;TD&gt;US00208J1088&lt;/TD&gt;&lt;TD&gt;US0025671050&lt;/TD&gt;&lt;TD&gt;US0038301067&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;instead of &lt;SPAN style="font-size: 13.3333330154419px;"&gt; ar1&amp;nbsp; ar2&amp;nbsp; ar3&amp;nbsp; ar4&amp;nbsp; ar5) and so on. Observations will remain same. Only variable names will have to be changed. How can I do that?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2015 01:00:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-the-variable-names/m-p/206477#M267146</guid>
      <dc:creator>AbuChowdhury</dc:creator>
      <dc:date>2015-03-20T01:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing the variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-the-variable-names/m-p/206478#M267147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since there's no discernable pattern you'll need to manually use rename statements. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rename ar1=CA35543 ar2=CH5783 etc;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2015 01:22:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-the-variable-names/m-p/206478#M267147</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-03-20T01:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing the variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-the-variable-names/m-p/206479#M267148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can't we use macro for this? I see from the following link.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="active_link" href="http://www.ats.ucla.edu/stat/sas/code/renaming_variables_dynamically.htm" title="http://www.ats.ucla.edu/stat/sas/code/renaming_variables_dynamically.htm"&gt;SAS Code Fragments: A few SAS macro programs for renaming variables dynamically&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But in scenario number 1, it changed the names of only two variables. How can do that for all of my variables?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2015 01:31:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-the-variable-names/m-p/206479#M267148</guid>
      <dc:creator>AbuChowdhury</dc:creator>
      <dc:date>2015-03-20T01:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing the variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-the-variable-names/m-p/206480#M267149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think that this code is helpful:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro rename1(oldvarlist, newvarlist);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let k=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let old = %scan(&amp;amp;oldvarlist, &amp;amp;k);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let new = %scan(&amp;amp;newvarlist, &amp;amp;k);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do %while(("&amp;amp;old" NE "") &amp;amp; ("&amp;amp;new" NE ""));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rename &amp;amp;old = &amp;amp;new;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %let k = %eval(&amp;amp;k + 1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let old = %scan(&amp;amp;oldvarlist, &amp;amp;k);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let new = %scan(&amp;amp;newvarlist, &amp;amp;k);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %rename1(ar1 ar2 ar3 ar4 ar5, CA45245E1097 CH0018666781 US00208J1088 US0025671050 US0038301067);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But if I have ar1, ar2,&amp;nbsp; ......., ar200, then what can I do? I tried with the following but it's not working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let oldvarlist= ar1-ar5;&lt;/P&gt;&lt;P&gt;%let newvarlist= CA45245E1097 CH0018666781 US00208J1088 US0025671050 US0038301067;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;data want ;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp; %rename1(&amp;amp;oldvarlist, &amp;amp;newvarlist);&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2015 01:56:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-the-variable-names/m-p/206480#M267149</guid>
      <dc:creator>AbuChowdhury</dc:creator>
      <dc:date>2015-03-20T01:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing the variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-the-variable-names/m-p/206481#M267150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I must have missed the part where you said you have 200 variables.&lt;/P&gt;&lt;P&gt;Do you have the name mappings somewhere?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See several options here:&lt;/P&gt;&lt;P&gt;&lt;A href="http://stackoverflow.com/questions/26971433/create-a-sequence-of-new-column-names/26982894#26982894" title="http://stackoverflow.com/questions/26971433/create-a-sequence-of-new-column-names/26982894#26982894"&gt;sas - Create a sequence of new column names - Stack Overflow&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2015 02:25:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-the-variable-names/m-p/206481#M267150</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-03-20T02:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing the variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-the-variable-names/m-p/206482#M267151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;I have names of the variables in this way:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;%let newvarlist= CA45245E1097 CH0018666781 US00208J1088 US0025671050 US0038301067 ..............;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2015 03:16:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-the-variable-names/m-p/206482#M267151</guid>
      <dc:creator>AbuChowdhury</dc:creator>
      <dc:date>2015-03-20T03:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing the variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-the-variable-names/m-p/206483#M267152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd recommend placing it into a dataset instead and using the answer from the link above. You wont need the first proc sql but the rest should be pretty much the same. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2015 03:20:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-the-variable-names/m-p/206483#M267152</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-03-20T03:20:35Z</dc:date>
    </item>
  </channel>
</rss>

