<?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: best practice to rename in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94955#M8670</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You rename variables in SAS using either proc datasets or in a data step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a datastep you are creating new data set whereas in proc datasets you're modifying your original dataset. Generally how you get variables listed is the issue. If you only need to do it once then typing it in, or copying it from excel is fine. If you need to do it multiple times, then I agree with Linus, the structure of your data is not optimal.&amp;nbsp; However, you can do it using macro variables. It's been illustrated many times on this forum so some searching should help you find it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a dataset:&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;rename&lt;/P&gt;&lt;P&gt;P002001=tot_urban_rural&lt;/P&gt;&lt;P&gt;P002002=tot_urban&lt;/P&gt;&lt;P&gt;P002003=inside_urbanized_areas&lt;/P&gt;&lt;P&gt;P002004=inside_urban_clusters;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In proc datasets:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc datasets library=work;&lt;/P&gt;&lt;P&gt;modify have;&lt;/P&gt;&lt;P&gt;rename&lt;/P&gt;&lt;P&gt;P002001=tot_urban_rural&lt;/P&gt;&lt;P&gt;P002002=tot_urban&lt;/P&gt;&lt;P&gt;P002003=inside_urbanized_areas&lt;/P&gt;&lt;P&gt;P002004=inside_urban_clusters;&lt;/P&gt;&lt;P&gt;run;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 Feb 2013 16:31:49 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2013-02-04T16:31:49Z</dc:date>
    <item>
      <title>best practice to rename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94946#M8661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have more than one dataset in the sas which has more than 1000 variables. all these variables are specific code (eg: 1234,6789, 4343, ect). I have once excelsheet which mentioned all these code (eg: 1234,6789, 4343, ect) along with variable explanation (eg: 1234=total_population).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my question is what is the best practice to implement that excel sheet into the sas dataset so that it rename 1234=total_population and with all other code to particular name?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2013 18:33:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94946#M8661</guid>
      <dc:creator>sas_9</dc:creator>
      <dc:date>2013-02-01T18:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: best practice to rename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94947#M8662</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you do a proc contents on your SAS data set what are the names of your variables? (are they really 235,6789?)&lt;BR /&gt;I thought SAS doesn't allow for column names to be just digits:smileyconfused:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2013 18:52:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94947#M8662</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-02-01T18:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: best practice to rename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94948#M8663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="809401" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;: Actually it does if you have the validvarname option set to ANY, but I wouldn't recommend doing that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="3209" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;: It would help if you tell us more and provide a brief example (i.e., NOT with 1,000 variables)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2013 19:13:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94948#M8663</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-02-01T19:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: best practice to rename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94949#M8664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P&gt;Arthur Tabachneck wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;A _jive_internal="true" data-containerid="-1" data-containertype="-1" data-objectid="809401" data-objecttype="3" href="https://communities.sas.com/people/AncaTilea"&gt;Anca tilea&lt;/A&gt;: Actually it does if you have the validvarname option set to ANY, but I wouldn't recommend doing that.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;A _jive_internal="true" data-containerid="-1" data-containertype="-1" data-objectid="3209" data-objecttype="3" href="https://communities.sas.com/people/sandy_24cena"&gt;sandip&amp;nbsp; patel&lt;/A&gt;: It would help if you tell us more and provide a brief example (i.e., NOT with 1,000 variables)&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;Thank you,Arthur.&lt;/P&gt;&lt;P&gt;Here is a non SAS question: how do I reference someone in my reply (like you just did)??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2013 19:15:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94949#M8664</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-02-01T19:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: best practice to rename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94950#M8665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="809401" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; Start by typing the @ symbol, then immediately follow the symbol by typing the person's screen name.&amp;nbsp; Doesn't work for all names, but does for most.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2013 19:20:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94950#M8665</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-02-01T19:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: best practice to rename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94951#M8666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="149594" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;:smileylaugh:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2013 19:21:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94951#M8666</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-02-01T19:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: best practice to rename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94952#M8667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If its in an excel sheet I typically create a new column in excel using functions that looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;oldname1=newname1&lt;/P&gt;&lt;P&gt;oldname2=newname2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And then copy and paste that into SAS code with the rename statement. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I add a rename before the names and a semi colon afterwards. &lt;/P&gt;&lt;P&gt;There are more automated solutions but this works as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2013 20:05:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94952#M8667</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-02-01T20:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: best practice to rename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94953#M8668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would say that best practice (in most scenarios) is not to have tables with hundred/thousands of columns. I quite positive it will be easier for you if you transpose your data, and then you can use standard table lookup techniques, like joins, merge, user defined formats etc to apply descriptions to your codes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2013 20:17:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94953#M8668</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-02-01T20:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: best practice to rename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94954#M8669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@Arthur - sir, i have variable like&lt;/P&gt;&lt;P&gt;P002001&lt;/P&gt;&lt;P&gt;P002002&lt;/P&gt;&lt;P&gt;P002003&lt;/P&gt;&lt;P&gt;P002004&lt;/P&gt;&lt;P&gt;and many more lwith this kind of code - wanted to change to&lt;/P&gt;&lt;P&gt;P002001=tot_urban_rural&lt;/P&gt;&lt;P&gt;P002002=tot_urban&lt;/P&gt;&lt;P&gt;P002003=inside_urbanized_areas&lt;/P&gt;&lt;P&gt;P002004=inside_urban_clusters&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have excel sheet with code (P002001) and actual variable name (tot_urban_rural) that i wants to rename it...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks all for your feedback&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Feb 2013 16:25:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94954#M8669</guid>
      <dc:creator>sas_9</dc:creator>
      <dc:date>2013-02-04T16:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: best practice to rename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94955#M8670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You rename variables in SAS using either proc datasets or in a data step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a datastep you are creating new data set whereas in proc datasets you're modifying your original dataset. Generally how you get variables listed is the issue. If you only need to do it once then typing it in, or copying it from excel is fine. If you need to do it multiple times, then I agree with Linus, the structure of your data is not optimal.&amp;nbsp; However, you can do it using macro variables. It's been illustrated many times on this forum so some searching should help you find it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a dataset:&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;rename&lt;/P&gt;&lt;P&gt;P002001=tot_urban_rural&lt;/P&gt;&lt;P&gt;P002002=tot_urban&lt;/P&gt;&lt;P&gt;P002003=inside_urbanized_areas&lt;/P&gt;&lt;P&gt;P002004=inside_urban_clusters;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In proc datasets:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc datasets library=work;&lt;/P&gt;&lt;P&gt;modify have;&lt;/P&gt;&lt;P&gt;rename&lt;/P&gt;&lt;P&gt;P002001=tot_urban_rural&lt;/P&gt;&lt;P&gt;P002002=tot_urban&lt;/P&gt;&lt;P&gt;P002003=inside_urbanized_areas&lt;/P&gt;&lt;P&gt;P002004=inside_urban_clusters;&lt;/P&gt;&lt;P&gt;run;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Feb 2013 16:31:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94955#M8670</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-02-04T16:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: best practice to rename</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94956#M8671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="3209" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;: Here is an example using Fareeza's suggested code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data spreadsheet;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat name $32.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input var $ name;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;P002001 tot_urban_rural&lt;/P&gt;&lt;P&gt;P002002 tot_urban&lt;/P&gt;&lt;P&gt;P002003 inside_urbanized_areas&lt;/P&gt;&lt;P&gt;P002004 inside_urban_clusters&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select strip(var)||'='||strip(name)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :renames separated by " "&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from spreadsheet&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input p002001 p002002 p002003 p002004;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;1 2 3 4&lt;/P&gt;&lt;P&gt;5 6 7 8&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; rename &amp;amp;renames.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc datasets library=work;&lt;/P&gt;&lt;P&gt;&amp;nbsp; modify have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; rename &amp;amp;renames.;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Feb 2013 17:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/best-practice-to-rename/m-p/94956#M8671</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-02-04T17:13:29Z</dc:date>
    </item>
  </channel>
</rss>

