BookmarkSubscribeRSS Feed
daisy6
Quartz | Level 8

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,

 

 

3 REPLIES 3
ballardw
Super User

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.

RickAster
Obsidian | Level 7

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.

daisy6
Quartz | Level 8

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!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 3155 views
  • 0 likes
  • 3 in conversation