<?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 with last letter =1 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/rename-all-variables-with-last-letter-1/m-p/94428#M19906</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Pretty close to what Linlin suggest but using a RegEx to match more precisely the variables you want renamed - and using Proc Datasets instead of a Data Step to do the renaming (and so avoiding a full pass through the data).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data class;&lt;BR /&gt;&amp;nbsp; set sashelp.class;&lt;BR /&gt;&amp;nbsp; newage1=age;&lt;BR /&gt;&amp;nbsp; newweight1=weight;&lt;BR /&gt;&amp;nbsp; newheight1=height;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;&amp;nbsp; select cats(name,'=',prxchange('s/(.+)(1\b)/$1/o',1,name)) into : list separated by ' '&lt;BR /&gt;&amp;nbsp;&amp;nbsp; from dictionary.columns&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname='WORK' and memname='CLASS' and prxmatch('/.+1\b/',name)&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc datasets lib=work nolist;&lt;BR /&gt;&amp;nbsp; modify class;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rename &amp;amp;list;&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Aug 2012 14:08:53 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2012-08-15T14:08:53Z</dc:date>
    <item>
      <title>rename all variables with last letter =1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-all-variables-with-last-letter-1/m-p/94426#M19904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;what is the best way to rename my variables?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;data class;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp; set sashelp.class;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; newage1=age;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; newweight1=weight;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;newheight1=heigt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;I have a lot of variables end with '1'. I want to take out '1'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;in my example, I need to rename newage1=newage and all other variables.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;Thanks! &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 12:57:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-all-variables-with-last-letter-1/m-p/94426#M19904</guid>
      <dc:creator>HG</dc:creator>
      <dc:date>2012-08-15T12:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: rename all variables with last letter =1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-all-variables-with-last-letter-1/m-p/94427#M19905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;how about:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data class;&lt;BR /&gt;&amp;nbsp; set sashelp.class (obs=1);&lt;BR /&gt;&amp;nbsp; newage1=age;&lt;BR /&gt;&amp;nbsp; neww1=weight;&lt;BR /&gt;&amp;nbsp; newh1=height;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; select catx('=',name,substr(name,1,length(name)-1)) into : list separated by ' '&lt;BR /&gt;&amp;nbsp;&amp;nbsp; from dictionary.columns&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname='WORK' and memname='CLASS' and substr(name,length(name))='1';&lt;BR /&gt; quit;&lt;/P&gt;&lt;P&gt; data newclass;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; set class;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; rename &amp;amp;list;&lt;BR /&gt; run;&lt;BR /&gt; proc print;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 13:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-all-variables-with-last-letter-1/m-p/94427#M19905</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-08-15T13:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: rename all variables with last letter =1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rename-all-variables-with-last-letter-1/m-p/94428#M19906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Pretty close to what Linlin suggest but using a RegEx to match more precisely the variables you want renamed - and using Proc Datasets instead of a Data Step to do the renaming (and so avoiding a full pass through the data).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data class;&lt;BR /&gt;&amp;nbsp; set sashelp.class;&lt;BR /&gt;&amp;nbsp; newage1=age;&lt;BR /&gt;&amp;nbsp; newweight1=weight;&lt;BR /&gt;&amp;nbsp; newheight1=height;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;&amp;nbsp; select cats(name,'=',prxchange('s/(.+)(1\b)/$1/o',1,name)) into : list separated by ' '&lt;BR /&gt;&amp;nbsp;&amp;nbsp; from dictionary.columns&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname='WORK' and memname='CLASS' and prxmatch('/.+1\b/',name)&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc datasets lib=work nolist;&lt;BR /&gt;&amp;nbsp; modify class;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rename &amp;amp;list;&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 14:08:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rename-all-variables-with-last-letter-1/m-p/94428#M19906</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-08-15T14:08:53Z</dc:date>
    </item>
  </channel>
</rss>

