Help using Base SAS procedures

Proc SQL, Tough one: Merge 2 datasets, many to many Match Merge

Reply
Contributor
Posts: 58

Proc SQL, Tough one: Merge 2 datasets, many to many Match Merge

Ok, so the previous thread i started, i don't think can be accomplished as stated. But i think this will work:

I'm trying to do a many-to-many match merge, but i have a problem: rather than having 1 variable = 1 variable, i have 5 variables to merge "by". I don't think i can do this in SAS, but it would also work to have the 5 variables compound to one variable showing each of the permutations of the 5, then doing the merge by the new single variable. I could then do the merge using Proc SQL with: one variable showing the permutations = one variable showing the permutations.

Can anyone show me how to do this?

Thanks!
Super Contributor
Posts: 578

Re: Proc SQL, Tough one: Merge 2 datasets, many to many Match Merge

do you mean something like this?

proc sql;
select * from tab1 t1 outer join tab2 t2 on t1.var1=t2.var1 and t1.var2=t2.var2 and t1.var3=t2.var3 and t1.var4=t2.var4 and t1.var5=t2.var5;
quit;
Contributor
Posts: 58

Re: Proc SQL, Tough one: Merge 2 datasets, many to many Match Merge

That's exactly what i mean. Though i ended up concatenating the variables to form one variable.
Ask a Question
Discussion stats
  • 2 replies
  • 154 views
  • 0 likes
  • 2 in conversation