DATA Step, Macro, Functions and more

Proc compare no output observations

Frequent Contributor
Posts: 102

Proc compare no output observations

Hi experts,

I use proc compare to test whether two datasets have same values. Here is the code:

proc compare base=aa compare=bb out=comparing criterion=0.01;
var  A B C D PropA propB propc propd;
with  a b c d a_1 b_1 c_1 d_1 ;
id regid;
by regid;


the log window shows:

There were 4805 observations read from the data set WORK.AA.
NOTE: There were 4531 observations read from the data set WORK.BB.
NOTE: The data set WORK.COMPARING has 0 observations and 28 variables.
NOTE: PROCEDURE COMPARE used (Total process time):

The BB dataset has 4805 obs two, why the log window shows 4531 obs. And the output dataset comparing has 0 obs. There is no error warning on log window. What is wrong with my program?




Super User
Posts: 13,523

Re: Proc compare no output observations

By default, the OUT= data set contains an observation for each pair of matching observations.


No output records should mean that there were no matches on ALL of the variables involved.


You may want one of the options OUTALL, OUTBASE, OUTCOMP instead of the OUTDIF which is the default.

Posts: 22

Re: Proc compare no output observations

I was unable to reproduce the discrepancy in observation count for BB, but I reproduced the other results when I used two input data sets AA and BB that had no values of REGID in common. If you want the output data set to include nonmatching observations, remove the BY statement and add the OUTALL option to the PROC COMPARE statement.

Frequent Contributor
Posts: 102

Re: Proc compare no output observations

Posted in reply to RickAster

Thanks for reply! I use the other way to solve it.  By using aa.a-bb.a to test whether they have the same value. Thanks any way! By the way, I use the same code to test the other two datasets and the code works well, so that I believe there should be something wrong with my data, not my code. Thanks anyway!

Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation