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;
run;
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?
Thanks,
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.
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.
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!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.