08-09-2017 01:07 PM
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 ;
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?
08-09-2017 02:08 PM
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.
08-09-2017 02:19 PM
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.
08-09-2017 02:36 PM
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!