I have several tables
Table1:
Var1
A
B
C
D
E
F
G
Table 2:
Var2
A
D
F
G
Table 3:
Var3
B
C
D
F
G
i want to get these into a single table in the form of
Var1 Var2 Var3
A A
B B
C C
D D D
E
F F F
G G G
any suggestions?
proc sql;
create table want as
select *
from table1 a
full join table2 b on a.var1 = b.var2
full join table3 c on a.var1 = c.var3
;
run;
proc sql;
create table want as
select *
from table1 a
full join table2 b on a.var1 = b.var2
full join table3 c on a.var1 = c.var3
;
run;
What do you mean by "it is not working"? Can you include your data and code, and the results you are seeing?
Could be solved with a merge, if you don't mind creating a common key-variable in all dataset:
data Table1;
input Var1 $;
key = Var1;
datalines;
A
B
C
D
E
F
G
;
run;
data Table2;
input Var2 $;
key = Var2;
datalines;
A
D
F
G
;
run;
data Table3;
input Var3 $;
key = Var3;
datalines;
B
C
D
F
G
;
run;
data all;
merge Table1 Table2 Table3;
by key;
drop Key;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: