<?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: How to rename all variable with same occurrences in name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-rename-all-variable-with-same-occurrences-in-name/m-p/562733#M157671</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/276197"&gt;@jennyshop&lt;/a&gt;&amp;nbsp;anytime, glad to help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 30 May 2019 22:39:31 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-05-30T22:39:31Z</dc:date>
    <item>
      <title>How to rename all variable with same occurrences in name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-rename-all-variable-with-same-occurrences-in-name/m-p/562714#M157657</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Can someone help me.&amp;nbsp; I want to rename all the variables in a dataset that have a certain value in the name. I have hundreds of variables.&amp;nbsp; For example. address2018, city2018, state2018.&amp;nbsp; Is there anyway I can change them all to address2019, city2019, state2019.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Jenny&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 20:50:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-rename-all-variable-with-same-occurrences-in-name/m-p/562714#M157657</guid>
      <dc:creator>jennyshop</dc:creator>
      <dc:date>2019-05-30T20:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename all variable with same occurrences in name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-rename-all-variable-with-same-occurrences-in-name/m-p/562721#M157661</link>
      <description>&lt;P&gt;Hi and welcome to the SAS Communities &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is one way&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data somedata;
input address2018 $ city2018 $ state2018 $ var1-var3;
datalines;
a b c 1 2 3
a b c 1 2 3
a b c 1 2 3
a b c 1 2 3
a b c 1 2 3
a b c 1 2 3
;

data _null_;
   set sashelp.vcolumn end=lr;
   where libname='WORK' and memname='SOMEDATA';

   if _n_ = 1 then 
      call execute('proc datasets lib=work nolist; modify somedata;');
   if find(name, '2018') ne 0 then 
      call execute('rename '|| name || '=' || tranwrd(name, '2018', '2019') ||';');

   if lr then call execute('quit;');
run;

proc contents data=somedata;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 21:16:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-rename-all-variable-with-same-occurrences-in-name/m-p/562721#M157661</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-05-30T21:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename all variable with same occurrences in name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-rename-all-variable-with-same-occurrences-in-name/m-p/562725#M157665</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/276197"&gt;@jennyshop&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Can someone help me.&amp;nbsp; I want to rename all the variables in a dataset that have a certain value in the name. I have hundreds of variables.&amp;nbsp; For example. address2018, city2018, state2018.&amp;nbsp; Is there anyway I can change them all to address2019, city2019, state2019.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;/P&gt;
&lt;P&gt;Jenny&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Or prevent the entire issue by having a variable such as YEAR with the value of 2018 and all of the variables with names like address, city, state.&lt;/P&gt;
&lt;P&gt;Then if you have another "year" data it has the same structure and you can append the data and process or model using the YEAR variable for grouping or reporting.&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 22:03:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-rename-all-variable-with-same-occurrences-in-name/m-p/562725#M157665</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-30T22:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename all variable with same occurrences in name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-rename-all-variable-with-same-occurrences-in-name/m-p/562730#M157669</link>
      <description>&lt;P&gt;Draycut:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;It worked.&amp;nbsp; THANK YOU!!!!&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 22:32:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-rename-all-variable-with-same-occurrences-in-name/m-p/562730#M157669</guid>
      <dc:creator>jennyshop</dc:creator>
      <dc:date>2019-05-30T22:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename all variable with same occurrences in name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-rename-all-variable-with-same-occurrences-in-name/m-p/562733#M157671</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/276197"&gt;@jennyshop&lt;/a&gt;&amp;nbsp;anytime, glad to help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 22:39:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-rename-all-variable-with-same-occurrences-in-name/m-p/562733#M157671</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-05-30T22:39:31Z</dc:date>
    </item>
  </channel>
</rss>

