<?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 Can PROC COMPARE show variables having equal values but different names? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Can-PROC-COMPARE-show-variables-having-equal-values-but/m-p/39101#M10049</link>
    <description>I'm trying to use a different data source for my reports.  The alternate COMPARE dataset/table has the same observations as the old source BASE dataset/table, plus some additional observations,  but the variable names are different.  Some are easy to determine just by looking, but most are not intuitive at all.  I want to map the two in a cross-reference, if you will, to point my code to the correct new variable names in the alternate dataset without altering the logic in the program.  Is there an option in PROC COMPARE to show in two different datasets, variables having equal values but different names.&lt;BR /&gt;
&lt;BR /&gt;
Here is my PROC COMPARE code below:&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=whse.acls_detail_all out=jesslibr.detail_all_base nodup;  /*  THIS IS THE BASE dataset   */&lt;BR /&gt;
by acct_num ;&lt;BR /&gt;
run;&lt;BR /&gt;
data jesslibr.bbacls_201005_test ;&lt;BR /&gt;
  length acct_num $ 18 ;&lt;BR /&gt;
   set jesslibr.bbacls_201005 ;&lt;BR /&gt;
acct_num = substr(source_key_value,13,18) ;&lt;BR /&gt;
format acct_num $18. ;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=jesslibr.bbacls_201005_test out=jesslibr.bbacls_201005_comp nodup ; /*  THIS IS THE COMPARE dataset   */&lt;BR /&gt;
by acct_num ;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/**      Begin PROC COMPARE of the two sorted datasets.      **/&lt;BR /&gt;
&lt;BR /&gt;
ods listing close; &lt;BR /&gt;
options linesize= 120 pagesize= 80;&lt;BR /&gt;
proc compare base=jesslibr.detail_all_base &lt;BR /&gt;
             compare=jesslibr.bbacls_201005_comp  LISTCOMPVAR BRIEFSUMMARY  out=jesslibr.proc_compare_results_acls  maxprint=10;&lt;BR /&gt;
			 by acct_num;&lt;BR /&gt;
			 &lt;BR /&gt;
&lt;BR /&gt;
title1 "Variables In May2010 dataset Acls_Detail_All of equal value but different name in May2010 dataset BBacls_201005" ;&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
ods listing;</description>
    <pubDate>Tue, 22 Jun 2010 18:26:44 GMT</pubDate>
    <dc:creator>chandler</dc:creator>
    <dc:date>2010-06-22T18:26:44Z</dc:date>
    <item>
      <title>Can PROC COMPARE show variables having equal values but different names?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-PROC-COMPARE-show-variables-having-equal-values-but/m-p/39101#M10049</link>
      <description>I'm trying to use a different data source for my reports.  The alternate COMPARE dataset/table has the same observations as the old source BASE dataset/table, plus some additional observations,  but the variable names are different.  Some are easy to determine just by looking, but most are not intuitive at all.  I want to map the two in a cross-reference, if you will, to point my code to the correct new variable names in the alternate dataset without altering the logic in the program.  Is there an option in PROC COMPARE to show in two different datasets, variables having equal values but different names.&lt;BR /&gt;
&lt;BR /&gt;
Here is my PROC COMPARE code below:&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=whse.acls_detail_all out=jesslibr.detail_all_base nodup;  /*  THIS IS THE BASE dataset   */&lt;BR /&gt;
by acct_num ;&lt;BR /&gt;
run;&lt;BR /&gt;
data jesslibr.bbacls_201005_test ;&lt;BR /&gt;
  length acct_num $ 18 ;&lt;BR /&gt;
   set jesslibr.bbacls_201005 ;&lt;BR /&gt;
acct_num = substr(source_key_value,13,18) ;&lt;BR /&gt;
format acct_num $18. ;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=jesslibr.bbacls_201005_test out=jesslibr.bbacls_201005_comp nodup ; /*  THIS IS THE COMPARE dataset   */&lt;BR /&gt;
by acct_num ;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/**      Begin PROC COMPARE of the two sorted datasets.      **/&lt;BR /&gt;
&lt;BR /&gt;
ods listing close; &lt;BR /&gt;
options linesize= 120 pagesize= 80;&lt;BR /&gt;
proc compare base=jesslibr.detail_all_base &lt;BR /&gt;
             compare=jesslibr.bbacls_201005_comp  LISTCOMPVAR BRIEFSUMMARY  out=jesslibr.proc_compare_results_acls  maxprint=10;&lt;BR /&gt;
			 by acct_num;&lt;BR /&gt;
			 &lt;BR /&gt;
&lt;BR /&gt;
title1 "Variables In May2010 dataset Acls_Detail_All of equal value but different name in May2010 dataset BBacls_201005" ;&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
ods listing;</description>
      <pubDate>Tue, 22 Jun 2010 18:26:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-PROC-COMPARE-show-variables-having-equal-values-but/m-p/39101#M10049</guid>
      <dc:creator>chandler</dc:creator>
      <dc:date>2010-06-22T18:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Can PROC COMPARE show variables having equal values but different names?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-PROC-COMPARE-show-variables-having-equal-values-but/m-p/39102#M10050</link>
      <description>I don't know of a PROC COMPARE option for that but you can cause PROC COMPARE to compare a variable to a number of other variables using the VAR and WITH statements.  For numeric variable you could look at summary statistics to help ID variables that are equal but have different name.&lt;BR /&gt;
&lt;BR /&gt;
Here is example of comparing AGE to all the other numeric variables in a different data set to find a match.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data class;&lt;BR /&gt;
   set sashelp.class;&lt;BR /&gt;
   rename age=age1 weight=age2 height=age3;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc compare base=sashelp.class compare=class listequalvar novalues;&lt;BR /&gt;
   var age age age;&lt;BR /&gt;
   with _numeric_;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
You could automate this by preparing lists of variables from each data set, using PROC TRANSPOSE or PROC CONTENTS and code gen calls to PROC COMPARE.</description>
      <pubDate>Tue, 22 Jun 2010 20:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-PROC-COMPARE-show-variables-having-equal-values-but/m-p/39102#M10050</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-06-22T20:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Can PROC COMPARE show variables having equal values but different names?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-PROC-COMPARE-show-variables-having-equal-values-but/m-p/39103#M10051</link>
      <description>Thanks Data _NULL_ ;  I believe I follow your logic in the example you gave here, and I am trying to apply it to my situation, but the last comment you made about "automate this by preparing lists of variables from each dataset, using PROC TRANSPOSE or PROC CONTENS and code gen calls to PROC COMPARE", I can't visualize that.  I need examples of how to do that.  I have 877 variables and 40,236 observations in my BASE dataset and 145 variables and 64,364 observations in the COMPARE dataset.</description>
      <pubDate>Wed, 23 Jun 2010 15:52:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-PROC-COMPARE-show-variables-having-equal-values-but/m-p/39103#M10051</guid>
      <dc:creator>chandler</dc:creator>
      <dc:date>2010-06-23T15:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: Can PROC COMPARE show variables having equal values but different names?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-PROC-COMPARE-show-variables-having-equal-values-but/m-p/39104#M10052</link>
      <description>Here is an example of a program that may work for you.  I don't know what kind of performance you can expect with so many variables.  This program compares each numeric variable in BASE with every other numeric variable in COMPARE.  &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
*** Create sample data;&lt;BR /&gt;
data base;&lt;BR /&gt;
   set sashelp.class(in=in1) sashelp.class(in=in2);&lt;BR /&gt;
   byvar = cats(of in:);&lt;BR /&gt;
   run;&lt;BR /&gt;
 &lt;BR /&gt;
data compare;&lt;BR /&gt;
   set sashelp.class(in=in1) sashelp.class(in=in2);&lt;BR /&gt;
   byvar = cats(of in:);&lt;BR /&gt;
   rename age=agey;&lt;BR /&gt;
   rename weight=wt;&lt;BR /&gt;
   today = today();&lt;BR /&gt;
   if in2 and name eq: 'J' then do;&lt;BR /&gt;
      age + ranuni(1);&lt;BR /&gt;
      height = ranuni(1);&lt;BR /&gt;
      end;&lt;BR /&gt;
   run;&lt;BR /&gt;
 &lt;BR /&gt;
*** get a list of numeric variable names from BASE DATA;&lt;BR /&gt;
proc transpose data=base(obs=0) out=baseVars;&lt;BR /&gt;
   var _numeric_;&lt;BR /&gt;
   run;&lt;BR /&gt;
*** code gen VAR and WITH statements;&lt;BR /&gt;
filename FT33F001 temp;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
   file FT33F001;&lt;BR /&gt;
   if 0 then set compare(keep=_numeric_);&lt;BR /&gt;
   array _n&lt;LI&gt; _numeric_;&lt;BR /&gt;
   cvar0 = dim(_n);&lt;BR /&gt;
   do until(eof);&lt;BR /&gt;
      set baseVars end=eof;&lt;BR /&gt;
      do i = 1 to cvar0;&lt;BR /&gt;
         put +3 'Var ' _name_ +(-1) ';'; &lt;BR /&gt;
         end;&lt;BR /&gt;
      put +3 'with _numeric_;';&lt;BR /&gt;
      end;&lt;BR /&gt;
   run;&lt;BR /&gt;
*** compare;&lt;BR /&gt;
proc compare noprint base=base compare=compare novalues /*listequalvar note*/ OUTSTATS=stats;&lt;BR /&gt;
   by NOTSORTED byvar;&lt;BR /&gt;
   %inc FT33F001 / source2;&lt;BR /&gt;
   run;&lt;BR /&gt;
 &lt;BR /&gt;
*** this may be enough information to answer your question;&lt;BR /&gt;
proc print data=stats;&lt;BR /&gt;
   where _TYPE_ eq 'NDIF';&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
The NDIF statistics is Number of OBS different in the _BASE_ column with %dif in the _COMP_ column.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
      Obs    byvar    _VAR_     _WITH_    _TYPE_    _BASE_     _COMP_    _DIF_    _PCTDIF_&lt;BR /&gt;
&lt;BR /&gt;
        9     10      Age       agey       NDIF        0        0.000      .          .&lt;BR /&gt;
       20     10      Age       Height     NDIF       19      100.000      .          .&lt;BR /&gt;
       31     10      Age       wt         NDIF       19      100.000      .          .&lt;BR /&gt;
       42     10      Age       today      NDIF       19      100.000      .          .&lt;BR /&gt;
       53     10      Height    agey       NDIF       19      100.000      .          .&lt;BR /&gt;
       64     10      Height    Height     NDIF        0        0.000      .          .&lt;BR /&gt;
       75     10      Height    wt         NDIF       19      100.000      .          .&lt;BR /&gt;
       86     10      Height    today      NDIF       19      100.000      .          .&lt;BR /&gt;
       97     10      Weight    agey       NDIF       19      100.000      .          .&lt;BR /&gt;
      108     10      Weight    Height     NDIF       19      100.000      .          .&lt;BR /&gt;
      119     10      Weight    wt         NDIF        0        0.000      .          .&lt;BR /&gt;
      130     10      Weight    today      NDIF       19      100.000      .          .&lt;BR /&gt;
      141     01      Age       agey       NDIF        7       36.842      .          .&lt;BR /&gt;
      152     01      Age       Height     NDIF       19      100.000      .          .&lt;BR /&gt;
      163     01      Age       wt         NDIF       19      100.000      .          .&lt;BR /&gt;
      174     01      Age       today      NDIF       19      100.000      .          .&lt;BR /&gt;
      185     01      Height    agey       NDIF       19      100.000      .          .&lt;BR /&gt;
      196     01      Height    Height     NDIF        7       36.842      .          .&lt;BR /&gt;
      207     01      Height    wt         NDIF       19      100.000      .          .&lt;BR /&gt;
      218     01      Height    today      NDIF       19      100.000      .          .&lt;BR /&gt;
      229     01      Weight    agey       NDIF       19      100.000      .          .&lt;BR /&gt;
      240     01      Weight    Height     NDIF       19      100.000      .          .&lt;BR /&gt;
      251     01      Weight    wt         NDIF        0        0.000      .          .&lt;BR /&gt;
      262     01      Weight    today      NDIF       19      100.000      .          .&lt;BR /&gt;
[/pre]&lt;/LI&gt;</description>
      <pubDate>Thu, 24 Jun 2010 13:50:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-PROC-COMPARE-show-variables-having-equal-values-but/m-p/39104#M10052</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-06-24T13:50:12Z</dc:date>
    </item>
  </channel>
</rss>

