<?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 macro? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/375676#M65352</link>
    <description>&lt;P&gt;Similar to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;'s approach, but using a proc sql created macro variable:&lt;/P&gt;
&lt;PRE&gt;data test;
  infile datalines dsd;
  input Oldname : $150. Pre : $100. Post : $100. Newname : $150.;
datalines;
gr_major_get_yes, gr_major_get, yes, gr_major_get___yes
gr_img_com_abn_metr_gyr, gr_img_com, abn_metr_gyr, gr_img_com___abn_metr_gyr
if_excu_con_mer, if_excu, con_mer, if_excu___con_mer
roi_num_email_view_yes, roi_num_email_view, yes, roi_num_email_view___yes
exe_name_find_com_br_dis_seq, exe_name_find, com_br_dis_seq, exe_name_find___com_br_dis_seq
;

data have;
  input gr_major_get_yes gr_img_com_abn_metr_gyr if_excu_con_mer
  roi_num_email_view_yes exe_name_find_com_br_dis_seq;
  cards;
1 2 3 4 5
5 4 3 2 1
;

proc sql noprint;
  select catt(oldname,'=',newname)
    into :renames separated by ' '
      from test
  ;
quit;

data want;
  set have (rename=(&amp;amp;renames.));
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jul 2017 12:58:53 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2017-07-13T12:58:53Z</dc:date>
    <item>
      <title>Rename macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/375662#M65348</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a oldname list below (I use proc contents to get that).&amp;nbsp; I am trying to rename the list containing both Pre and Post strings.&amp;nbsp;&amp;nbsp; The Newname will be added three underscores between Pre and Post string.&amp;nbsp;&amp;nbsp;My actual dataset&amp;nbsp;have 300 similar oldname list,&amp;nbsp;&amp;nbsp; I am looking for if I could set up a macro to do it.&amp;nbsp; &amp;nbsp;Please advice how to approach it.&amp;nbsp; Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;infile&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; datalines &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;dsd&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Oldname : &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$150.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Pre : &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$100.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Post : &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$100.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Newname : &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$150.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;gr_major_get_yes, gr_major_get, yes, gr_major_get___yes&lt;/P&gt;
&lt;P&gt;gr_img_com_abn_metr_gyr, gr_img_com, abn_metr_gyr, gr_img_com___abn_metr_gyr&lt;/P&gt;
&lt;P&gt;if_excu_con_mer, if_excu, con_mer, if_excu___con_mer&lt;/P&gt;
&lt;P&gt;roi_num_email_view_yes, roi_num_email_view, yes, roi_num_email_view___yes&lt;/P&gt;
&lt;P&gt;exe_name_find_com_br_dis_seq, exe_name_find, com_br_dis_seq, exe_name_find___com_br_dis_seq&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 12:31:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/375662#M65348</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-13T12:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Rename macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/375670#M65350</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set test end=done;
if _n_ = 1 then call execute('data want; set have; rename ');
call execute(trim(oldname) !! '=' !! trim(newname) !! ' ');
if done then call execute ('; run;');
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jul 2017 12:44:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/375670#M65350</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-13T12:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: Rename macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/375676#M65352</link>
      <description>&lt;P&gt;Similar to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;'s approach, but using a proc sql created macro variable:&lt;/P&gt;
&lt;PRE&gt;data test;
  infile datalines dsd;
  input Oldname : $150. Pre : $100. Post : $100. Newname : $150.;
datalines;
gr_major_get_yes, gr_major_get, yes, gr_major_get___yes
gr_img_com_abn_metr_gyr, gr_img_com, abn_metr_gyr, gr_img_com___abn_metr_gyr
if_excu_con_mer, if_excu, con_mer, if_excu___con_mer
roi_num_email_view_yes, roi_num_email_view, yes, roi_num_email_view___yes
exe_name_find_com_br_dis_seq, exe_name_find, com_br_dis_seq, exe_name_find___com_br_dis_seq
;

data have;
  input gr_major_get_yes gr_img_com_abn_metr_gyr if_excu_con_mer
  roi_num_email_view_yes exe_name_find_com_br_dis_seq;
  cards;
1 2 3 4 5
5 4 3 2 1
;

proc sql noprint;
  select catt(oldname,'=',newname)
    into :renames separated by ' '
      from test
  ;
quit;

data want;
  set have (rename=(&amp;amp;renames.));
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 12:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/375676#M65352</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-13T12:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Rename macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/375688#M65355</link>
      <description>&lt;P&gt;Thanks, all of your prompt replys.&amp;nbsp;&amp;nbsp; Now, I have more chanllenging situation.&amp;nbsp;&amp;nbsp; I got other sources, the names they provided are various.&amp;nbsp; For example, the 'gr_major_get_yes' could become 'gr_major_get__yes' or 'gr_major_get_yes'.&amp;nbsp;&amp;nbsp; However, one things in common is all of them containing 'Pre'&amp;nbsp;string and 'Post' string.&amp;nbsp;&amp;nbsp; Is there a way could modefy your macro&amp;nbsp;codes based on the 'Pre' and 'Post' conditions, instead of 'Oldname'.&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 13:57:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/375688#M65355</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-13T13:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: Rename macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/375693#M65356</link>
      <description>&lt;P&gt;You can only automate things which have a logic that can be expressed in an algorithm. "might be" is very hard to code &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;To automate a rename, you have to have a clear rule how the new name is built from the old name.&lt;/P&gt;
&lt;P&gt;Or you have a complete lookup list which is as it is.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 14:03:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/375693#M65356</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-13T14:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: Rename macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/375741#M65359</link>
      <description>&lt;P&gt;So, can I&amp;nbsp;put 'where' or 'if' statement in front of the call execute?&amp;nbsp; Something like, where oldname in ('pre' and 'post') ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call &lt;SPAN class="token keyword"&gt;&lt;FONT color="#0000ff"&gt;execute&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;(&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;&lt;FONT color="#0000ff"&gt;trim&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;(&lt;/FONT&gt;&lt;/SPAN&gt;oldname&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;)&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;!!&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;&lt;FONT color="#800000"&gt;'='&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;!!&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;&lt;FONT color="#0000ff"&gt;trim&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;(&lt;/FONT&gt;&lt;/SPAN&gt;newname&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;)&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;!!&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;&lt;FONT color="#800000"&gt;' '&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color="#999999"&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#999999"&gt;&lt;SPAN class="token punctuation"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 15:45:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/375741#M65359</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-13T15:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: Rename macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/375742#M65360</link>
      <description>&lt;P&gt;What happened when you tried it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;So, can I&amp;nbsp;put 'where' or 'if' statement in front of the call execute?&amp;nbsp; Something like, where oldname in ('pre' and 'post') ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call &lt;SPAN class="token keyword"&gt;&lt;FONT color="#0000ff"&gt;execute&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;(&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;&lt;FONT color="#0000ff"&gt;trim&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;(&lt;/FONT&gt;&lt;/SPAN&gt;oldname&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;)&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;!!&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;&lt;FONT color="#800000"&gt;'='&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;!!&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;&lt;FONT color="#0000ff"&gt;trim&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;(&lt;/FONT&gt;&lt;/SPAN&gt;newname&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;)&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;!!&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;&lt;FONT color="#800000"&gt;' '&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT color="#999999"&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#999999"&gt;&lt;SPAN class="token punctuation"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 15:46:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/375742#M65360</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-13T15:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: Rename macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/376148#M65378</link>
      <description>&lt;P&gt;Hi, Kurt:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I modified your code below.&amp;nbsp; However, I got an error message.&amp;nbsp; Could you help me where went wrong?&amp;nbsp; Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;infile&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; datalines &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;dsd&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; name : &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$150.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Newname : &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$150.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;gr__major_get__yes, gr_major_get_yes&lt;/P&gt;
&lt;P&gt;gr_img_com___abn_metr_gyr, gr_img_com_abn_metr_gyr&lt;/P&gt;
&lt;P&gt;if_excu_con_mer__, if_excu_con_mer&lt;/P&gt;
&lt;P&gt;_roi_num_email___view_yes_, roi_num_email_view_yes&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=done;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; _n_ = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; execute(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'data want; set test; rename '&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; execute(trim(name) !! &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'='&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; !! trim(newname) !! &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;' '&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; done &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; execute (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'; run;'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: CALL EXECUTE generated line.&lt;/P&gt;
&lt;P&gt;1 + data want; set test; rename&lt;/P&gt;
&lt;P&gt;2 + gr__major_get__yes=gr_major_get_yes&lt;/P&gt;
&lt;P&gt;3 + gr_img_com___abn_metr_gyr=gr_img_com_abn_metr_gyr&lt;/P&gt;
&lt;P&gt;4 + if_excu_con_mer__=if_excu_con_mer&lt;/P&gt;
&lt;P&gt;5 + _roi_num_email___view_yes_=roi_num_email_view_yes&lt;/P&gt;
&lt;P&gt;6 + ; run;&lt;/P&gt;
&lt;P&gt;WARNING: The variable gr__major_get__yes in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;
&lt;P&gt;WARNING: The variable gr_img_com___abn_metr_gyr in the DROP, KEEP, or RENAME list has never been&lt;/P&gt;
&lt;P&gt;referenced.&lt;/P&gt;
&lt;P&gt;WARNING: The variable if_excu_con_mer__ in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;
&lt;P&gt;WARNING: The variable _roi_num_email___view_yes_ in the DROP, KEEP, or RENAME list has never been&lt;/P&gt;
&lt;P&gt;referenced.&lt;/P&gt;
&lt;P&gt;NOTE: There were 4 observations read from the data set WORK.TEST.&lt;/P&gt;
&lt;P&gt;NOTE: The data set WORK.WANT has 4 observations and 2 variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2017 19:46:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/376148#M65378</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-14T19:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: Rename macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/376158#M65379</link>
      <description>&lt;P&gt;Within the first call execute, you have to use the dataset that contains the variables you want to rename, not the one that contains the lookup for the variable names.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2017 21:02:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/376158#M65379</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-14T21:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: Rename macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/376239#M65380</link>
      <description>&lt;P&gt;It sounds like you have a situation where you have names that start with specific lettters and end with other specific letters. How do you want to then transform the name? &amp;nbsp;If is as simple as converting PRExyzPOST into just xyz then you can use simple SAS functions. If it is more complex then perhaps you can write the rules using regular expressions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Get a list of varaible names, either using PROC CONTENTS or query the DICTIONARY.COLUMNS metadata.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=have out=contents noprint; run;
%let pre=PRE;
%let post=POST;
proc sql noprint;
  select catx('=',name,substr(name,%length(&amp;amp;pre)+1,length(name)-%length(&amp;amp;pre.&amp;amp;post)))
    into :renames separated by ' '
  from contents
  where upcase(name) like %upcase("&amp;amp;pre")||'%'||%upcase("&amp;amp;post")
  ;
quit;
data want ;
  set have ;
  rename &amp;amp;renames;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2017 14:11:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/376239#M65380</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-15T14:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: Rename macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/376260#M65381</link>
      <description>&lt;P&gt;Hi, Tom:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes.&amp;nbsp; I would like to add three underscore between the Pre and Post, which means Name =&amp;nbsp;&amp;amp;Pre___&amp;amp;Post.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2017 19:35:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/376260#M65381</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-15T19:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Rename macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/376262#M65382</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes.&amp;nbsp; I would like to add three underscore between the Pre and Post, which means Name =&amp;nbsp;&amp;amp;Pre___&amp;amp;Post.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is even easier, but perhaps you will have multiple names that try to get named to the same thing?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select catx('=',name,"&amp;amp;pre.___&amp;amp;post")
    into :renames separated by ' '
  from contents
  where upcase(name) like %upcase("&amp;amp;pre")||'%'||%upcase("&amp;amp;post")
  ;
quit;
data _null_;
  if &amp;amp;sqlobs &amp;gt; 1 then put 'ERROR: Name conflict.' "&amp;amp;renames" ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2017 20:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/376262#M65382</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-15T20:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Rename macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/376270#M65383</link>
      <description>&lt;P&gt;Hmm, I only have one 'Pre' and one 'Post' string correspose to one 'NewName',&amp;nbsp; So far!&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2017 20:49:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/376270#M65383</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-15T20:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Rename macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/376271#M65384</link>
      <description>&lt;P&gt;What is this '&lt;SPAN class="token statement"&gt;&lt;FONT color="#0000ff"&gt;where&lt;/FONT&gt;&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;&lt;FONT color="#0000ff"&gt;upcase&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;(&lt;/FONT&gt;&lt;/SPAN&gt;name&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;)&lt;/FONT&gt;&lt;/SPAN&gt; like &lt;SPAN class="token macroname"&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;FONT color="#000080"&gt;%upcase&lt;/FONT&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;(&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;&lt;FONT color="#800000"&gt;"&amp;amp;pre"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;)&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;||&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;&lt;FONT color="#800000"&gt;'%'&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&lt;FONT color="#a67f59"&gt;||&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token macroname"&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;FONT color="#000080"&gt;%upcase&lt;/FONT&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;(&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;&lt;FONT color="#800000"&gt;"&amp;amp;post"&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;&lt;FONT color="#999999"&gt;)' for?&amp;nbsp; Why have %&amp;nbsp; between those two %upcase?&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2017 20:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/376271#M65384</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-15T20:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Rename macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/377141#M65436</link>
      <description>&lt;P&gt;Thanks for everyone's great help.&amp;nbsp; I&amp;nbsp;have&amp;nbsp;tried three ways from Kurt, Art and Tom's suggestions.&amp;nbsp;&amp;nbsp; I had difficulty using Call symput, and Proc SQL where statement didn't work either.&amp;nbsp; However, I am appreciated all of experts making effort and spending time to answer my questions.&amp;nbsp; I learned a lot!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2017 21:23:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rename-macro/m-p/377141#M65436</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-18T21:23:13Z</dc:date>
    </item>
  </channel>
</rss>

