<?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 New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Rename-variables/m-p/594217#M15633</link>
    <description>&lt;P&gt;And you want to do so for all variables in a specific data set?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Oct 2019 20:07:29 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-10-04T20:07:29Z</dc:date>
    <item>
      <title>Rename variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rename-variables/m-p/594208#M15632</link>
      <description>&lt;P&gt;There are some variables that end in "zz". How to rename only those variables by removing "zz" from variable name?&lt;/P&gt;&lt;P&gt;For example Temperaturezz should be renamed to Temperature.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2019 19:37:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rename-variables/m-p/594208#M15632</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2019-10-04T19:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rename-variables/m-p/594217#M15633</link>
      <description>&lt;P&gt;And you want to do so for all variables in a specific data set?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2019 20:07:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rename-variables/m-p/594217#M15633</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-04T20:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rename-variables/m-p/594218#M15634</link>
      <description>&lt;P&gt;Yes. Most of the variables end with "zz" so would like to remove zz and those without zz Would like to keep them as is&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2019 20:10:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rename-variables/m-p/594218#M15634</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2019-10-04T20:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rename-variables/m-p/594224#M15636</link>
      <description>&lt;P&gt;Ok. 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 test;
input onezz two threezz;
datalines;
1 2 3
;
 
data _null_;
   set sashelp.vcolumn end=lr;
   where libname='WORK' and memname='TEST';
 
   if _n_ = 1 then 
      call execute('proc datasets lib=work nolist; modify test;');
 
   if substr(name,length(name)-1,2)='zz' then
      call execute(compbl(cat('rename ', name, '=', tranwrd(name, 'zz', ''), ';')));
 
   if lr then call execute('quit;');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Oct 2019 20:21:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rename-variables/m-p/594224#M15636</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-04T20:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Rename-variables/m-p/594248#M15638</link>
      <description>&lt;P&gt;Looks good, but you probably will want to tighten up the logic.&lt;/P&gt;
&lt;P&gt;Make sure test for names that end in ZZ or zZ or Zz also.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;lowcase(substr(name,length(name)-1,2))='zz'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also you don't want to remove the zz from the middle of a name like PIzzazz.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; call execute(catx(' ','rename',name,'=',substr(name,1,length(name)-2)))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2019 23:14:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Rename-variables/m-p/594248#M15638</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-04T23:14:12Z</dc:date>
    </item>
  </channel>
</rss>

