BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

I have done one-to-one and one-to-many match merge using SAS. However, I'm having trouble doing a many-to-many match merge. I hope someone can help me. For simplicity, assume that I have the following datasets:

First datasets:
VarA VarB
a1 a
a1 b
a1 c
a2 a
a2 d
a3 b
a3 f

Second datasets:
VarC VarA
c1 a1
c1 a2
c2 a1
c2 a3
c3 a1

Is there any way for me to merge the two datasets so that I will have the following:
VarC VarA VarB
c1 a1 a
c1 a1 b
c1 a1 c
c1 a2 a
c1 a2 d
c2 a1 a
c2 a1 b
c2 a1 c
c2 a3 b
c2 a3 f
c3 a1 a
c3 a1 b
c3 a1 c

I sorted both datasets by VarA and then merged the datasets by VarA but the results are not what I wanted. I think the above can be done as there is a logical sequence to the matching but I can't seem to do it. Can someone please help? Thanks!
2 REPLIES 2
deleted_user
Not applicable
proc sql;
create table manytomany as
select b.*, a.VarB
from secondset b, firstset a
where b.VarA=a.VarA;
deleted_user
Not applicable
Hi Vasile,

Thank you so much! I used your proc sql statement and got the dataset that I required. Cheers!
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
  • 2 replies
  • 1100 views
  • 1 like
  • 1 in conversation