<?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: Proc Compare or Rename in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30835#M7342</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does the WITH statement help you at all in proc compare? Then you can avoid renaming to the same name?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data class2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop height age;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if sex='F' then height2=height-1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else height2=height;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if sex='M' then age2=age/2; else age2=age;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc compare base=sashelp.class compare=class2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var age height;&lt;/P&gt;&lt;P&gt;with age2 height2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Jan 2012 21:48:14 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2012-01-16T21:48:14Z</dc:date>
    <item>
      <title>Proc Compare or Rename</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30834#M7341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not exactly sure how to go about doing this and was hoping someone could help.&amp;nbsp; I have numerous datasets that I want to compare, but the problem is that they have different column names.&amp;nbsp; Is there a way in a data step to rename part of a coloumn if it begins with a certain letter or set of letters?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if the coloum looked like this Base_period&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could I tell SAS to look for the letters Base and once found to rename to Curr, so it would now read Curr_period&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jan 2012 21:31:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30834#M7341</guid>
      <dc:creator>IgawaKei29</dc:creator>
      <dc:date>2012-01-16T21:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Compare or Rename</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30835#M7342</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does the WITH statement help you at all in proc compare? Then you can avoid renaming to the same name?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data class2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop height age;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if sex='F' then height2=height-1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else height2=height;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if sex='M' then age2=age/2; else age2=age;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc compare base=sashelp.class compare=class2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var age height;&lt;/P&gt;&lt;P&gt;with age2 height2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jan 2012 21:48:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30835#M7342</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-01-16T21:48:14Z</dc:date>
    </item>
    <item>
      <title>Proc Compare or Rename</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30836#M7343</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;﻿The issue is that in the data sets I am looking at there are a number of combination Base could be.&amp;nbsp; That's why I want to replace Base with Curr.&amp;nbsp; I wouldn't want to try and list out all 100 of so columns that I am trying to compare, just rename what I can.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my current code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc compare brief&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; base=data.Set1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compare=data.Set2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; method=percent criterion=2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out=data.test1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jan 2012 22:09:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30836#M7343</guid>
      <dc:creator>IgawaKei29</dc:creator>
      <dc:date>2012-01-16T22:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Compare or Rename</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30837#M7344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You can use this code to rename your variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input base_id base_age base_height;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 20 6.0&lt;/P&gt;&lt;P&gt;2 25 5.9&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;proc sql noprint ;&lt;/P&gt;&lt;P&gt;select catx('=',name,cats('curr_',scan(name,-1,'_'))) into : base separated by ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp; from dictionary.columns &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; where libname='WORK' and memname='HAVE' and name like 'base~_%' escape '~';&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%put &amp;amp;base ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;proc datasets library=work nolist;&lt;/P&gt;&lt;P&gt;modify have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; rename &amp;amp;base ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;proc print; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curr_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Obs&amp;nbsp;&amp;nbsp;&amp;nbsp; curr_id&amp;nbsp;&amp;nbsp;&amp;nbsp; curr_age&amp;nbsp;&amp;nbsp;&amp;nbsp; height&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6.0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 25&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5.9&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Linlin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jan 2012 23:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30837#M7344</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-01-16T23:04:37Z</dc:date>
    </item>
    <item>
      <title>Proc Compare or Rename</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30838#M7345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks I will try working with this code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2012 12:40:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30838#M7345</guid>
      <dc:creator>IgawaKei29</dc:creator>
      <dc:date>2012-01-17T12:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Compare or Rename</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30839#M7346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK I think I almost have it, however when I run the program I am getting an error that &amp;amp;base is not defined.&amp;nbsp; Here is my updated program:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;IMG alt="01-17-2012 12-56-44 PM.png" class="jive-image-thumbnail jive-image" height="375" onclick="" src="https://communities.sas.com/legacyfs/online/1399_01-17-2012 12-56-44 PM.png" width="624" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2012 17:57:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30839#M7346</guid>
      <dc:creator>IgawaKei29</dc:creator>
      <dc:date>2012-01-17T17:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Compare or Rename</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30840#M7347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi,&lt;/P&gt;&lt;P&gt; Libname and memname must be capital letters. please change memname='cp_???' to 'CP_???'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2012 18:05:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30840#M7347</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-01-17T18:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Compare or Rename</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30841#M7348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; That's it.. thank you so much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2012 18:11:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30841#M7348</guid>
      <dc:creator>IgawaKei29</dc:creator>
      <dc:date>2012-01-17T18:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Compare or Rename</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30842#M7349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One more follow up question.&amp;nbsp; I am running into the problem when my field is named : base_pct_cnt&amp;nbsp; when I run the code I end up with curr_base_cnt.&amp;nbsp; How would I alter my code to account for 3 or 4 _ seperators?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jan 2012 11:30:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30842#M7349</guid>
      <dc:creator>IgawaKei29</dc:creator>
      <dc:date>2012-01-20T11:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Compare or Rename</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30843#M7350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data have;
input base_id base_age base_pct_cnt ;
cards;
1 20 6.0
2 25 5.9
;
run;

proc sql noprint ;
select catx('=',name,cats('curr',substr(name,findc(name,'_')))) into : base separated by ' '
&amp;nbsp; from dictionary.columns
&amp;nbsp;&amp;nbsp; where libname='WORK' and memname='HAVE' and name like 'base~_%' escape '~';
quit;

%put &amp;amp;base ;

 

proc datasets library=work nolist;
modify have;
&amp;nbsp; rename &amp;amp;base ;
quit;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jan 2012 12:09:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30843#M7350</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-01-20T12:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Compare or Rename</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30844#M7351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Big help, thank you so much&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jan 2012 13:18:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Compare-or-Rename/m-p/30844#M7351</guid>
      <dc:creator>IgawaKei29</dc:creator>
      <dc:date>2012-01-20T13:18:55Z</dc:date>
    </item>
  </channel>
</rss>

