BookmarkSubscribeRSS Feed
Filipvdr
Pyrite | Level 9

I am using proc compare for the first time and i'm wondering if there is a possibility to do the following:

I have 2 datasets : H and F.

In both datasets i have 3 variables to match on so I putted them in my id statement, i have several variables to compare then.

The problem is for example:

H:

idA idB idC varA varB varC

1    1    1    a      b     c

1    2    3    c      d     f

F

idA idB idC varA varB varC

1    1    1    a      b     d

1    1    1    a      b     c

proc compare base=H compare=F out=test OUTALL OUTDIF OUTPERCENT;

   id idA idB idC  ;

   var varA varB varC;

run;

As you can see the 2 records in F are almost identical. I want the compare to compare the first record from H with all records from F. Is the proc compare the right proc to use or do you have other suggestions?

Regards

3 REPLIES 3
ballardw
Super User

If you want to compare the first (or any subset of recrods) from H with F you probably want to use Proc SQL.

What type of comparison(s) do you want?

Filipvdr
Pyrite | Level 9

Just to check of the value of varA in H corresponds/matches to varA in F

                                         varB in H corresponds/matches to varB in F ...

Astounding
PROC Star

No, PROC COMPARE is the wrong tool for the job.  It will compare each record from H with only a single record from F.

As was suggested, PROC SQL is probably the right tool for the job.  But you would have to specify more of what you are hoping to achieve to get more help.  For example ...  Are your data sets small enough to sort?  Are duplicate records possible?  Do you want to find every possible match if there is more than one?  Do you want to identify which records match and which ones don't?  Do you care about mismatches that appear in H but not in F, or do you also care about mismatches that appear in F but not in H? 

Matches/mismatches are a common programming problem.  If you can describe what you are hoping to achieve, you will get plenty of feedback.

Good luck. 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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