BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
John4
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

data want;

merge tab1 tab2 tab3;

run;

 

Regards,

Naveen Srinivasan

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

data want;

merge tab1 tab2 tab3;

run;

 

Regards,

Naveen Srinivasan

PeterClemmensen
Tourmaline | Level 20

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;
John4
Obsidian | Level 7

It's because I have more than 500 obersations in each data (tab1, tab2, tab3)

 

Kurt_Bremser
Super User

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.

SAS Innovate 2025: Register Today!

 

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.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 972 views
  • 3 likes
  • 4 in conversation