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!

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!

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
  • 2 replies
  • 599 views
  • 1 like
  • 1 in conversation