<?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: Why rename is not working? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-rename-is-not-working/m-p/879164#M347338</link>
    <description>&lt;P&gt;Try this:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  set sashelp.class(rename=(age=NEW_AGE));
  label NEW_AGE="New label for New Age";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Simplest way to see variables names and labels (if there are any) is to run:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=test;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
    <pubDate>Sat, 03 Jun 2023 15:09:52 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2023-06-03T15:09:52Z</dc:date>
    <item>
      <title>Why rename is not working?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-rename-is-not-working/m-p/879158#M347332</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I have a data set "EMP" with column name ID. When I try to rename it to EMPID, it's not renaming.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code:&lt;/P&gt;
&lt;P&gt;data test;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;set EMP (rename=(ID=EMPID));&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;No, errors, "test" data set is getting created with all observations but without renaming the column ID.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not able to understand why it is not renaming the column.&lt;/P&gt;
&lt;P&gt;I have tried like this also:&lt;/P&gt;
&lt;P&gt;data test;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set EMP;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;rename ID=EMPID;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;Please,&amp;nbsp; help me to understand what could be the reason and how to resolve it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I try to check the following code, it is working:&lt;/P&gt;
&lt;P&gt;data test1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; set sashelp.class;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;date test1_rename;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set test1 (rename=(NAME=EMPID));&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jun 2023 14:13:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-rename-is-not-working/m-p/879158#M347332</guid>
      <dc:creator>Moksha</dc:creator>
      <dc:date>2023-06-03T14:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why rename is not working?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-rename-is-not-working/m-p/879159#M347333</link>
      <description>&lt;P&gt;I have just realized that using the column also has a label 'ID' and hence though internally it is renaming the column but since the label is not changed, it is displaying ID instead of EMPID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone advise how to rename both column name and label?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jun 2023 14:42:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-rename-is-not-working/m-p/879159#M347333</guid>
      <dc:creator>Moksha</dc:creator>
      <dc:date>2023-06-03T14:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: Why rename is not working?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-rename-is-not-working/m-p/879163#M347337</link>
      <description>&lt;P&gt;I have tried the following and it is working:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set EMP;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; set test (rename(ID=EMPID));&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; label EMPID='EMPID';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;and it worked.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jun 2023 15:09:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-rename-is-not-working/m-p/879163#M347337</guid>
      <dc:creator>Moksha</dc:creator>
      <dc:date>2023-06-03T15:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: Why rename is not working?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-rename-is-not-working/m-p/879164#M347338</link>
      <description>&lt;P&gt;Try this:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  set sashelp.class(rename=(age=NEW_AGE));
  label NEW_AGE="New label for New Age";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Simplest way to see variables names and labels (if there are any) is to run:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=test;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jun 2023 15:09:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-rename-is-not-working/m-p/879164#M347338</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-06-03T15:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: Why rename is not working?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-rename-is-not-working/m-p/879165#M347339</link>
      <description>&lt;P&gt;Thank you. I have tried this and it also worked.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jun 2023 15:12:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-rename-is-not-working/m-p/879165#M347339</guid>
      <dc:creator>Moksha</dc:creator>
      <dc:date>2023-06-03T15:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: Why rename is not working?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-rename-is-not-working/m-p/879167#M347340</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/439180"&gt;@Moksha&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have just realized that using the column also has a label 'ID' and hence though internally it is renaming the column but since the label is not changed, it is displaying ID instead of EMPID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone advise how to rename both column name and label?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Proc datasets will do both to a set in place. No need to create a new data set or take the chance of corrupting data that can happen with a logic error in a Data step.&lt;/P&gt;
&lt;PRE&gt;Proc datasets library=yourlib nodetails nolist;
  modify somedatset;
  rename oldname=newname;
  label newname='New label text';
run;
quit;&lt;/PRE&gt;
&lt;P&gt;The nodetails and nolist options suppress printing some output to your results.&lt;/P&gt;
&lt;P&gt;You can have multiple rename and label pairs in a single rename or label statement if desired. You can also change formats.&lt;/P&gt;
&lt;P&gt;The procedure supports run group processing, such as modifying different data sets. So the procedure requires a Quit statement to end the procedure.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jun 2023 16:26:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-rename-is-not-working/m-p/879167#M347340</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-06-03T16:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: Why rename is not working?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-rename-is-not-working/m-p/879169#M347341</link>
      <description>&lt;P&gt;Thank you very much. I will definitely use this suggestion instead of new data set creation.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jun 2023 17:24:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-rename-is-not-working/m-p/879169#M347341</guid>
      <dc:creator>Moksha</dc:creator>
      <dc:date>2023-06-03T17:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: Why rename is not working?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-rename-is-not-working/m-p/879175#M347345</link>
      <description>&lt;P&gt;If you just remove the label then places that display labels instead of names will display the name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;label emplid=' ';&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Jun 2023 00:59:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-rename-is-not-working/m-p/879175#M347345</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-04T00:59:07Z</dc:date>
    </item>
  </channel>
</rss>

