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. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

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
  • 787 views
  • 0 likes
  • 3 in conversation