Help using Base SAS procedures

using proc compare

Reply
Regular Contributor
Posts: 229

using proc compare

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

Super User
Posts: 10,483

Re: using proc compare

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?

Regular Contributor
Posts: 229

Re: using proc compare

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 ...

Super User
Posts: 5,080

Re: using proc compare

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. 

Ask a Question
Discussion stats
  • 3 replies
  • 213 views
  • 0 likes
  • 3 in conversation