<?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: Rename Variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rename-Variables/m-p/112583#M259113</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Same idea as Tom, but if all you need is to rename, you don't have to create a new table, and if your table is huge, it will save you some time considerably. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select cats(visit2,'=',visit1) into :rename separated by ' ' from rename;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc datasets library=yourlibraryname nolist;&lt;/P&gt;&lt;P&gt;&amp;nbsp; modify visit2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; rename &amp;amp;rename;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Jun 2013 20:27:21 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2013-06-19T20:27:21Z</dc:date>
    <item>
      <title>Rename Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-Variables/m-p/112579#M259109</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I posted about this previously but think I got confused and in turn confused others so I am going to re-try here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am working on a longitudinal study collecting data at 5 points in time. We completed the first visit and created a new questionnaire for the second visit. However, our programmer made a mistake and if the question was the same, he created a new variable name instead of keeping it the same. What we wanted was the variable names to remain the same and for them to be identified by the variable "visit_number" to look at change over time. So I have an excel file that has all the variable names from visit 1, matched up with the variables names from visit 2 if the question was identical. What I need to do is convert the variable names from visit 2 to equal the variable name of visit 1 if the question was the same. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Visit 1 varname &lt;/SPAN&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; &lt;SPAN style="text-decoration: underline;"&gt;Visit 2 varname&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;travel6mo&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; trav6mo&lt;/P&gt;&lt;P&gt;varaa&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; varrra&lt;/P&gt;&lt;P&gt;usedrg&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; drguse&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I need the visit 2 varnames to be replaces by those in visit 1. I know I can use the RENAME statement but I have about 900 variables that need to be renamed, that is why we created an excel file first, to match things up. Please let me know if there is a way to do this. Please let me know if you have any questions. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2013 19:22:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-Variables/m-p/112579#M259109</guid>
      <dc:creator>rfarmenta</dc:creator>
      <dc:date>2013-06-19T19:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: Rename Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-Variables/m-p/112580#M259110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have two datasets (first visit and second visit)? Could you force append the 2nd dataset to a shell of the first dataset? The variable positions would have to be identical in both datasets for this to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you wouldnt have to code the renaming at all.&amp;nbsp; Not seeing the full structure of the data its hard to tell if this will help solve your problem or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2013 19:45:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-Variables/m-p/112580#M259110</guid>
      <dc:creator>esjackso</dc:creator>
      <dc:date>2013-06-19T19:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Rename Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-Variables/m-p/112581#M259111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The two data sets are not identical as several questions were removed from the questionnaire for follow up and a few new ones were added. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2013 20:04:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-Variables/m-p/112581#M259111</guid>
      <dc:creator>rfarmenta</dc:creator>
      <dc:date>2013-06-19T20:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: Rename Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-Variables/m-p/112582#M259112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use the list to generate code you can use in a RENAME statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint ;&lt;/P&gt;&lt;P&gt; select catx('=',Visit_2_varname,Visit_1_varname) into :renames separated by ' '&lt;/P&gt;&lt;P&gt; from &lt;STRONG&gt;mytable&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;data &lt;STRONG&gt;want&lt;/STRONG&gt; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set &lt;STRONG&gt;visit2&lt;/STRONG&gt; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; rename &amp;amp;renames;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2013 20:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-Variables/m-p/112582#M259112</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-06-19T20:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Rename Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-Variables/m-p/112583#M259113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Same idea as Tom, but if all you need is to rename, you don't have to create a new table, and if your table is huge, it will save you some time considerably. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select cats(visit2,'=',visit1) into :rename separated by ' ' from rename;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc datasets library=yourlibraryname nolist;&lt;/P&gt;&lt;P&gt;&amp;nbsp; modify visit2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; rename &amp;amp;rename;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2013 20:27:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-Variables/m-p/112583#M259113</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-06-19T20:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: Rename Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-Variables/m-p/112584#M259114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, I think Hai.Kuo's solution worked. I am going through to make sure everything matched up correctly. I will add an update tomorrow once I know everything worked correctly. I really appreciate everyone's expertise and willingness to help a novice trying to improve his skills. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2013 22:23:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-Variables/m-p/112584#M259114</guid>
      <dc:creator>rfarmenta</dc:creator>
      <dc:date>2013-06-19T22:23:30Z</dc:date>
    </item>
  </channel>
</rss>

