<?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 dropping a prefix in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/rename-variables-dropping-a-prefix/m-p/313155#M67990</link>
    <description>&lt;P&gt;so based on your understanding the issue was to find a valid SAS name for a dataset? Thanks for your effort but please avoid to spam the forum answering if you can contribute to solve the issue.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Nov 2016 16:53:49 GMT</pubDate>
    <dc:creator>Sir_Highbury</dc:creator>
    <dc:date>2016-11-21T16:53:49Z</dc:date>
    <item>
      <title>rename variables dropping a prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-variables-dropping-a-prefix/m-p/313054#M67956</link>
      <description>&lt;P&gt;Dear experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;givedn the following two datasets:&lt;/P&gt;&lt;P&gt;data a;&lt;BR /&gt;input country: $12. month_201601: $25. month_201602: $25. month_201603: $25.;&lt;BR /&gt;datalines;&lt;BR /&gt;russia 20 30 40 50&lt;BR /&gt;belgium 0 0 0 0&lt;BR /&gt;germany 10 20 30 40&lt;BR /&gt;;run;&lt;/P&gt;&lt;P&gt;data b;&lt;BR /&gt;input country: $12. sales_201601: $25. sales_201602: $25. sales_201603: $25.;&lt;BR /&gt;datalines;&lt;BR /&gt;russia 20 30 40 50&lt;BR /&gt;belgium 0 0 0 0&lt;BR /&gt;germany 10 20 30 40&lt;BR /&gt;;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to merge the data into a unique data set. How can I adjust the variable names droppin the prefix, i.e. sales_201601 renamed as 201601 and month201601 as 201601. Afterward I could easily append them. Thanks in advance, SH.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 13:21:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-variables-dropping-a-prefix/m-p/313054#M67956</guid>
      <dc:creator>Sir_Highbury</dc:creator>
      <dc:date>2016-11-21T13:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: rename variables dropping a prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-variables-dropping-a-prefix/m-p/313061#M67957</link>
      <description>&lt;P&gt;201601 is NOT a valid SAS name, it would be considered a numeric literal.&lt;/P&gt;
&lt;P&gt;And why are you reading numeric values into character variables?&lt;/P&gt;
&lt;P&gt;Once again, the benefits of a long vs. wide format come into play:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input country: $12. month_201601 month_201602 month_201603;
datalines;
russia 20 30 40 50
belgium 0 0 0 0
germany 10 20 30 40
;
run;

data b;
input country: $12. sales_201601 sales_201602 sales_201603;
datalines;
russia 20 30 40 50
belgium 0 0 0 0
germany 10 20 30 40
;
run;

proc transpose data=a out=a1;
by country notsorted;
run;

proc transpose data=b out=b1;
by country notsorted;
run;

data want;
set a1 b1;
_name_ = scan(_name_,2,'_');
rename col1=sales _name_=month;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can now use by-group processing to do analyses.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 13:40:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-variables-dropping-a-prefix/m-p/313061#M67957</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-11-21T13:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: rename variables dropping a prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-variables-dropping-a-prefix/m-p/313062#M67958</link>
      <description>&lt;P&gt;&lt;SPAN&gt;201601 is not a valid SAS Name for a dataset &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 13:41:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-variables-dropping-a-prefix/m-p/313062#M67958</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2016-11-21T13:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: rename variables dropping a prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-variables-dropping-a-prefix/m-p/313125#M67979</link>
      <description>&lt;P&gt;I would be interested in see the Proc Contents result run against the data set you are going to append this data set to.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 15:47:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-variables-dropping-a-prefix/m-p/313125#M67979</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-11-21T15:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: rename variables dropping a prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-variables-dropping-a-prefix/m-p/313155#M67990</link>
      <description>&lt;P&gt;so based on your understanding the issue was to find a valid SAS name for a dataset? Thanks for your effort but please avoid to spam the forum answering if you can contribute to solve the issue.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 16:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-variables-dropping-a-prefix/m-p/313155#M67990</guid>
      <dc:creator>Sir_Highbury</dc:creator>
      <dc:date>2016-11-21T16:53:49Z</dc:date>
    </item>
  </channel>
</rss>

