<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/rename-variables/m-p/333964#M75343</link>
    <description>&lt;P&gt;Thank you both, Reeza and Art! Your responses are both very helpful! Have a nice afternoon!&lt;/P&gt;</description>
    <pubDate>Fri, 17 Feb 2017 21:12:29 GMT</pubDate>
    <dc:creator>mikiduta</dc:creator>
    <dc:date>2017-02-17T21:12:29Z</dc:date>
    <item>
      <title>rename variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-variables/m-p/333945#M75337</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have a dataset with many variables, named as it follows:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;street_density, landuse_mix, street_connectivity, deprivation&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I would like to automatically rename them as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;x1=&amp;nbsp;street_density, x2=landuse_mix, x3=street_connectivity, x4=deprivation.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am looking for an easy way to do this for many variables simultaneously.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 20:45:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-variables/m-p/333945#M75337</guid>
      <dc:creator>mikiduta</dc:creator>
      <dc:date>2017-02-17T20:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: rename variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-variables/m-p/333946#M75338</link>
      <description>&lt;P&gt;I thought this was what you were asking in the first place. Please post the actual proc standard code that you ran.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 20:47:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-variables/m-p/333946#M75338</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-02-17T20:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: rename variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-variables/m-p/333960#M75341</link>
      <description>&lt;P&gt;The reason I asked you to post the proc standard code that you ran is because you can copy the variable list it contains into a data step, then use the proc sql method I mentioned earlier this afternoon. Here is an example using sashelp.class:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;PROC STANDARD DATA= sashelp.class MEAN=0 STD=1 OUT=zscoreswk;
  VAR age height weight;
run;

data need;
  input;
  _n_=1;
  do while (scan(_infile_,_n_) ne '');
    var=scan(_infile_,_n_);
    output;
    _n_+1;
  end;
  cards;
age height weight
;

proc sql noprint;
  select catt(var,'=z_',var)
    into :vars separated by ' '
      from need
  ;
quit;

data zscoreswk;
  set zscoreswk;
  rename &amp;amp;vars.;
run;
&lt;/PRE&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 21:07:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-variables/m-p/333960#M75341</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-02-17T21:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: rename variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-variables/m-p/333962#M75342</link>
      <description>&lt;P&gt;Here's an example of renaming, using the sashelp library. I've broken it out into more steps that ideally necessary, but it helps you to understand what's happening. You can combine steps as you're comfortable with the program.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
set sashelp.class;
run;

data names;
set sashelp.vcolumn;
where libname='SASHELP' and memname='CLASS';

new_name = catt("X", _n_);

keep new_name name;
run;

proc sql noprint;
select catx("=", name, new_name) into :rename_list separated by " "
from names;
quit;

proc datasets lib=work nodetails nolist;
modify class;
rename &amp;amp;rename_list;
run;quit;




&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Feb 2017 21:10:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-variables/m-p/333962#M75342</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-17T21:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: rename variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-variables/m-p/333964#M75343</link>
      <description>&lt;P&gt;Thank you both, Reeza and Art! Your responses are both very helpful! Have a nice afternoon!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 21:12:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-variables/m-p/333964#M75343</guid>
      <dc:creator>mikiduta</dc:creator>
      <dc:date>2017-02-17T21:12:29Z</dc:date>
    </item>
  </channel>
</rss>

