I have 3 data : tab1, tab2 and tab3 like this :
tab1 :
NAME1 NUMBER1
John 145
Max 200
tab2 :
NAME2 NUMBER2
Johny 1415
Maximus 4200
Vince 765
and tab3 :
NAME3 NUMBER3
Johnatan 145
Bruce 200
How to do a join like this ? :
NAME 1 NUMBER1 NAME2 NUMBER2 NAME3 NUMBER3
John 145 Johny 1415 Johnatan 145
Max 200 Maximus 4200 Bruce 200
. . Vince 765 . .
data want;
merge tab1 tab2 tab3;
run;
Regards,
Naveen Srinivasan
It can be done like below.
But why do you want your data like this? Does not seem logical?
data tab1;
input NAME1 $ NUMBER1;
datalines;
John 145
Max 200
;
data tab2;
input NAME2 $ NUMBER2;
datalines;
Johny 1415
Maximus 4200
Vince 765
;
data tab3;
input NAME3 $ NUMBER3;
datalines;
Johnatan 145
Bruce 200
;
data want;
merge tab1-tab3;
run;
It's because I have more than 500 obersations in each data (tab1, tab2, tab3)
Yeah, but why the wide structure that only makes your work more tedious in the future?
I'd much prefer
data want;
set
tab1 (rename=(name1=name number1=number))
tab2 (rename=(name2=name number2=number))
tab3 (rename=(name3=name number3=number))
;
run;
To get a unified table.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.