<?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 many columns with underscore prefix  dynamically in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/rename-many-columns-with-underscore-prefix-dynamically/m-p/413584#M101255</link>
    <description>&lt;P&gt;Thanks a lot Tom ! it works exactly as intended&lt;/P&gt;&lt;P&gt;thanks to others users for your responses&lt;/P&gt;</description>
    <pubDate>Wed, 15 Nov 2017 08:26:00 GMT</pubDate>
    <dc:creator>Nasser_DRMCP</dc:creator>
    <dc:date>2017-11-15T08:26:00Z</dc:date>
    <item>
      <title>rename many columns with underscore prefix  dynamically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-many-columns-with-underscore-prefix-dynamically/m-p/413416#M101173</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get a dataset with 36 columns names&amp;nbsp; _1601 , _1602, _1603 ....._1911 and _1912&lt;/P&gt;&lt;P&gt;that corresponds to year month ("_" appears because of proc import csv file in which columns are named&amp;nbsp;&amp;nbsp;is 1601 1602...)&lt;/P&gt;&lt;P&gt;I would like to rename them as 1601, 1602...1912 or replace "_" by "month"&lt;/P&gt;&lt;P&gt;Thanks a lot for your help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind &amp;nbsp;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Nasser&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 17:28:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-many-columns-with-underscore-prefix-dynamically/m-p/413416#M101173</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2017-11-14T17:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: rename many columns with underscore prefix  dynamically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-many-columns-with-underscore-prefix-dynamically/m-p/413442#M101185</link>
      <description>&lt;P&gt;A better idea is to not do this, and instead use the method in Maxim 19 of &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_self"&gt;Maxims of Maximally Efficient SAS Programmers&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC TRANSPOSE should get you there.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 20:12:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-many-columns-with-underscore-prefix-dynamically/m-p/413442#M101185</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-11-14T20:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: rename many columns with underscore prefix  dynamically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-many-columns-with-underscore-prefix-dynamically/m-p/413459#M101194</link>
      <description>&lt;P&gt;1601 1602 are non valis sas names.&lt;/P&gt;
&lt;P&gt;A valis sas name shouls start with either an alphabetic character or _ or some other few special characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See details in next link:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000998953.htm" target="_self"&gt;https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000998953.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 20:08:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-many-columns-with-underscore-prefix-dynamically/m-p/413459#M101194</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-11-14T20:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: rename many columns with underscore prefix  dynamically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-many-columns-with-underscore-prefix-dynamically/m-p/413486#M101200</link>
      <description>&lt;P&gt;Get the list of names into data.&amp;nbsp; You could use PROC CONTENTS or query SAS's metadata tables.&lt;/P&gt;
&lt;P&gt;Store the list of oldname=newname pairs into a macro variable.&lt;/P&gt;
&lt;P&gt;Use the list in a RENAME statement or option&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is one way using PROC TRANSPOSE to get the names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have(obs=0)  out=names ;
  var _: ;
run;
proc sql noprint ;
  select catx('=',_name_,tranwrd(_name_,'_','month')
    into :renames separated by ' '
  from names
  ;
quit;
proc datasets libname=work nolist;
  modify have ;
    rename &amp;amp;renames ;
  run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Nov 2017 21:40:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-many-columns-with-underscore-prefix-dynamically/m-p/413486#M101200</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-14T21:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: rename many columns with underscore prefix  dynamically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-many-columns-with-underscore-prefix-dynamically/m-p/413513#M101213</link>
      <description>&lt;P&gt;I agree with &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;and would go one step further to make the "month" variable actually have a DATE value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   x= '1602';
   y=input(x,yymmn4.);
   Put 'Y as date9. ' y= date9. +1 'Y as yymon. ' y= yymon. 'y as yyQ. ' y=yyq.;
run;&lt;/PRE&gt;
&lt;P&gt;With a date value you can request summaries on that month value that would group by a specified format. So you could run proc means to sum by Year, quarter of the year, or month of the year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you wanted to create a summary or analysis for a specific interval you could use&amp;nbsp;&amp;nbsp; '01Feb2016'd le month le '01Aug2017'd to select records in that interval for example.&lt;/P&gt;
&lt;P&gt;Also your graphs with dates tend to display&amp;nbsp; better as graph that goes from 1606 to 1702 (assuming June 2016 to Feb 2017) has a very irregular boundary at the year boundary.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 22:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-many-columns-with-underscore-prefix-dynamically/m-p/413513#M101213</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-11-14T22:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: rename many columns with underscore prefix  dynamically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-many-columns-with-underscore-prefix-dynamically/m-p/413584#M101255</link>
      <description>&lt;P&gt;Thanks a lot Tom ! it works exactly as intended&lt;/P&gt;&lt;P&gt;thanks to others users for your responses&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 08:26:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-many-columns-with-underscore-prefix-dynamically/m-p/413584#M101255</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2017-11-15T08:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: rename many columns with underscore prefix  dynamically</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-many-columns-with-underscore-prefix-dynamically/m-p/413648#M101273</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I agree with &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;and would go one step further to make the "month" variable actually have a DATE value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;While I certainly would have done this if I was programming it myself, I am glad you mentioned it here, as I clearly forgot to mention it.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 13:37:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-many-columns-with-underscore-prefix-dynamically/m-p/413648#M101273</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-11-15T13:37:28Z</dc:date>
    </item>
  </channel>
</rss>

