<?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 Output mismatches in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-COMPARE-Output-mismatches/m-p/937757#M83589</link>
    <description>&lt;P&gt;Please always include code when asking a question about "can I do this". What you have done may well influence the options needed to get a working solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is one example that creates and output data set of observations in one data set not in the other. It starts with a data set that you should have available so you can actually run the code an see the results. The first set copies a data set, the second copies the same data set except for 4 observations. The OUTBASE requests the observations from the BASE=dataset (the larger one in this case) the OUTNOEQUAL suppresses the observations that have an equal observation in Compare= dataset. Result has the 4 observations in the base set not in the compare.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data class1;
   set sashelp.class;
run;

data class2;
   set sashelp.class (obs=15);
run;

proc compare base=class1 compare=class2 out=result outbase outnoequal;
run;&lt;/PRE&gt;
&lt;P&gt;This example will not work exactly with your data set because you have so many not equal values that either your data sets are not sorted the same (generally a very good idea with Proc Compare) OR you should severely restrict what is being compared. Possibly need an ID variable(s) and perhaps VAR and WITH statements.&lt;/P&gt;</description>
    <pubDate>Wed, 31 Jul 2024 14:05:38 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-07-31T14:05:38Z</dc:date>
    <item>
      <title>PROC COMPARE Output mismatches</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-COMPARE-Output-mismatches/m-p/937720#M83585</link>
      <description>&lt;P&gt;I have done a proc compare across 2 datasets. Can anyone advise if there is a method to output the 58 cases from Observation Summary onto an dataset?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sasheadache_0-1722411723730.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/98858iD3378E5BDD9A7028/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sasheadache_0-1722411723730.png" alt="sasheadache_0-1722411723730.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 07:45:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-COMPARE-Output-mismatches/m-p/937720#M83585</guid>
      <dc:creator>sasheadache</dc:creator>
      <dc:date>2024-07-31T07:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: PROC COMPARE Output mismatches</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-COMPARE-Output-mismatches/m-p/937729#M83586</link>
      <description>&lt;P&gt;&lt;FONT size="4"&gt;I suppose you are comparing observations with an ID Variable.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;... and your _1_ dataset has 58 observations (IDs) that are not found in your _2_ dataset.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Not sure if PROC COMPARE can output these 58 observations in a dataset.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;But you can always use PROC SQL or a data step to accomplish this of course.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;Koen&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 09:56:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-COMPARE-Output-mismatches/m-p/937729#M83586</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2024-07-31T09:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: PROC COMPARE Output mismatches</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-COMPARE-Output-mismatches/m-p/937731#M83587</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440127"&gt;@sasheadache&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this particular case you can select the last 58 observations from the base dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set BAU_0000_1_CASH_COLLECTED(firstobs=52452);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the more general case, where you don't know which of the two datasets has more observations and where you don't want to hardcode the first observation number to read from that dataset, you can use something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
if 0 then do;
  set BAU_0000_1_CASH_COLLECTED nobs=n1;
  set BAU_0000_2_CASH_COLLECTED nobs=n2;
end;
if n1&amp;gt;n2 then merge BAU_0000_1_CASH_COLLECTED(in=in1)
                    BAU_0000_2_CASH_COLLECTED(in=in2 drop=_all_);
         else merge BAU_0000_1_CASH_COLLECTED(in=in1 drop=_all_)
                    BAU_0000_2_CASH_COLLECTED(in=in2);
if in1 ne in2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Jul 2024 10:00:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-COMPARE-Output-mismatches/m-p/937731#M83587</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-07-31T10:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: PROC COMPARE Output mismatches</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-COMPARE-Output-mismatches/m-p/937757#M83589</link>
      <description>&lt;P&gt;Please always include code when asking a question about "can I do this". What you have done may well influence the options needed to get a working solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is one example that creates and output data set of observations in one data set not in the other. It starts with a data set that you should have available so you can actually run the code an see the results. The first set copies a data set, the second copies the same data set except for 4 observations. The OUTBASE requests the observations from the BASE=dataset (the larger one in this case) the OUTNOEQUAL suppresses the observations that have an equal observation in Compare= dataset. Result has the 4 observations in the base set not in the compare.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data class1;
   set sashelp.class;
run;

data class2;
   set sashelp.class (obs=15);
run;

proc compare base=class1 compare=class2 out=result outbase outnoequal;
run;&lt;/PRE&gt;
&lt;P&gt;This example will not work exactly with your data set because you have so many not equal values that either your data sets are not sorted the same (generally a very good idea with Proc Compare) OR you should severely restrict what is being compared. Possibly need an ID variable(s) and perhaps VAR and WITH statements.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 14:05:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-COMPARE-Output-mismatches/m-p/937757#M83589</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-07-31T14:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: PROC COMPARE Output mismatches</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-COMPARE-Output-mismatches/m-p/942127#M83626</link>
      <description>&lt;P&gt;To output the 58 cases from the Observation Summary of a &lt;CODE&gt;PROC COMPARE&lt;/CODE&gt; into a dataset, you can use the &lt;CODE&gt;OUT=&lt;/CODE&gt; option with the &lt;CODE&gt;OUTNOEQUAL&lt;/CODE&gt; and &lt;CODE&gt;OUTBASE&lt;/CODE&gt; (or &lt;CODE&gt;OUTCOMPARE&lt;/CODE&gt;, depending on which dataset's mismatches you want to capture) options in your &lt;CODE&gt;PROC COMPARE&lt;/CODE&gt; statement. Here’s an example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc compare base=dataset1 compare=dataset2 out=compared_diff outnoequal outbase;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;CODE&gt;outnoequal&lt;/CODE&gt; ensures that only the observations that differ between the datasets are included in the output dataset.&lt;/LI&gt;&lt;LI&gt;&lt;CODE&gt;outbase&lt;/CODE&gt; includes the observations from the base dataset in the output dataset.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2024 01:31:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-COMPARE-Output-mismatches/m-p/942127#M83626</guid>
      <dc:creator>Sarath_A_SAS</dc:creator>
      <dc:date>2024-09-02T01:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: PROC COMPARE Output mismatches</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-COMPARE-Output-mismatches/m-p/942313#M83627</link>
      <description>&lt;P&gt;Here's a minor tweak on&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;'s suggestion.&amp;nbsp; This code avoids reading through the matching observations before accepting the "extras".&amp;nbsp; Instead, it uses "firstobs=" to jump directly to the extra obs in the longer dataset:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data _null_;
  if 0 then set BAU_0000_1_CASH_COLLECTED nobs=n1;
  if 0 then set BAU_0000_2_CASH_COLLECTED nobs=n2;
  if n1^=n2;
  fobs=min(n1,n2)+1;
  call execute ('data want;');
  call execute (catx(' ','set',ifc(n1&amp;gt;n2,'BAU_0000_1_CASH_COLLECTED','BAU_0000_2_CASH_COLLECTED'),'(firstobs=',fobs,');'));
  call execute ('run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Sep 2024 14:45:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-COMPARE-Output-mismatches/m-p/942313#M83627</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-09-03T14:45:07Z</dc:date>
    </item>
  </channel>
</rss>

