<?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 all variables by adding a term at the end in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/264297#M51823</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Its giving me errors - Variable not found!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Help&lt;/P&gt;</description>
    <pubDate>Fri, 15 Apr 2016 21:33:16 GMT</pubDate>
    <dc:creator>AZIQ1</dc:creator>
    <dc:date>2016-04-15T21:33:16Z</dc:date>
    <item>
      <title>Rename all variables by adding a term at the end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/242505#M45018</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have 2 dataset that have similar variables. One file is for daily and the other file is for monthly.&lt;/P&gt;
&lt;P&gt;I want to add a term say "_daily" after all variables in daily file and "_monthly" for those in monthly file.&lt;/P&gt;
&lt;P&gt;Is there any way to do so instead of using the rename one by one?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input time var1x var3;&lt;BR /&gt;datalines;&lt;BR /&gt;1 1 1&lt;BR /&gt;2 3 5&lt;BR /&gt;1 2 3&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Jan 2016 01:15:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/242505#M45018</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2016-01-09T01:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables by adding a term at the end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/242506#M45019</link>
      <description>&lt;P&gt;Use metadata (SASHELP.VCOLUMN or DICTIONARY.COLUMNS or output of PROC CONTENTS) to generate the rename code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint ;
  select catx('=',name,cats(name,'_monthly'))
    into :monthly separated by ' '
    from dictionary.columns
    where libname='WORK'
      and memname='MONTHLY'
  ;
quit;
data want ;
   set monthly (rename=(&amp;amp;monthly)) ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 09 Jan 2016 01:25:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/242506#M45019</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-01-09T01:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables by adding a term at the end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/242510#M45020</link>
      <description>&lt;P&gt;Slight modification to Tom's code - I would suggest using proc datasets to modify the variable names instead.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're merging the files though, do it in that step instead of a separate rename step.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Jan 2016 02:37:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/242510#M45020</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-09T02:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables by adding a term at the end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/242653#M45055</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input time var1x var3;
datalines;
1 1 1
2 3 5
1 2 3
;
run;


data _null_;
 set sashelp.vcolumn(where=(libname='WORK' and memname='HAVE') keep=libname memname name) end=last;
 if _n_ eq 1 then call execute('proc datasets library=work nolist nodetails;modify have;rename');
 call execute(cats(name,'=',name,'_daily'));
 if last then call execute(';quit;');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Jan 2016 05:31:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/242653#M45055</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-11T05:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables by adding a term at the end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/257421#M49420</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I used this code and it worked successfully. But before this step I want to remove "_" from all my variable names - is there a quick way? I tried using compress with your code but failed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2016 19:22:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/257421#M49420</guid>
      <dc:creator>AZIQ1</dc:creator>
      <dc:date>2016-03-17T19:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables by adding a term at the end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/257423#M49421</link>
      <description>&lt;P&gt;The same steps should apply. &amp;nbsp;Try just running the part that calculates the new variable name from the old name in a data step so you can look at the result and figure&amp;nbsp;what is happening.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_name = compress(name,'_');
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Mar 2016 19:27:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/257423#M49421</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-03-17T19:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables by adding a term at the end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/257426#M49422</link>
      <description>Thank you, now need a step to keep the ones without '_' as is. My data has a mix of vars with '_' and some without.</description>
      <pubDate>Thu, 17 Mar 2016 19:32:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/257426#M49422</guid>
      <dc:creator>AZIQ1</dc:creator>
      <dc:date>2016-03-17T19:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables by adding a term at the end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/257486#M49444</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not findc(name,'_') then  call execute(cats(name,'=',name,'_daily'));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Mar 2016 00:49:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/257486#M49444</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-18T00:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables by adding a term at the end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/264007#M51720</link>
      <description>&lt;P&gt;Thank you can I apply the same logic or code to change the labels for all my variables - i mean i want to add a term before the label name for all vars:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;something like this:&lt;/P&gt;&lt;P&gt;PROC CONTENTS DATA=sat1 OUT=tmp_sat2;&lt;BR /&gt;RUN;&lt;BR /&gt;data _null_;&lt;BR /&gt;set WORK.tmp_SAT2(where=(libname='WORK' and memname='SAT1') keep=libname memname label) end=last;&lt;BR /&gt;if _n_ eq 1 then call execute('proc datasets library=work nolist nodetails;modify SAT1;LABEL');&lt;BR /&gt;call execute(cats(label,'=','SAT_',label));&lt;BR /&gt;if last then call execute(';quit;');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your feedback is highly appreciated&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 20:28:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/264007#M51720</guid>
      <dc:creator>AZIQ1</dc:creator>
      <dc:date>2016-04-14T20:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables by adding a term at the end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/264076#M51753</link>
      <description>Sure. Your code looks good .</description>
      <pubDate>Fri, 15 Apr 2016 04:44:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/264076#M51753</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-15T04:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables by adding a term at the end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/264297#M51823</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Its giving me errors - Variable not found!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Help&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 21:33:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/264297#M51823</guid>
      <dc:creator>AZIQ1</dc:creator>
      <dc:date>2016-04-15T21:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all variables by adding a term at the end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/264325#M51835</link>
      <description>Can you post the content of table tmp_SAT2 ,
and in
call execute(cats(label,'=','SAT_',label));
you use the same variable name at the both side, That doesn't look right.</description>
      <pubDate>Sat, 16 Apr 2016 03:01:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-variables-by-adding-a-term-at-the-end/m-p/264325#M51835</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-16T03:01:34Z</dc:date>
    </item>
  </channel>
</rss>

