Hello,
I would like to add a column to Table 1, the "des" column.
If table1.cat = table2.id then table1.des = table2.des
Table1:
Cat | Name |
1 | zer |
4 | tez |
3 | dgr |
1 | ffz |
1 | fzgtjt |
2 | pojn |
2 | fj |
3 | kfi |
3 | ndonz |
Table 2
id | des |
1 | com |
2 | the |
3 | action |
4 | sade |
And the table that I receive
Cat | Name | des |
1 | zer | com |
4 | tez | sade |
3 | dgr | action |
1 | ffz | com |
1 | fzgtjt | com |
2 | pojn | the |
2 | fj | the |
3 | kfi | action |
3 | ndonz | action |
Thanks for your help
Do like this
data table1;
input Cat Name $10.;
datalines;
1 zer
4 tez
3 dgr
1 ffz
1 fzgtjt
2 pojn
2 fj
3 kfi
3 ndonz
;
data table2;
input id des $10.;
datalines;
1 com
2 the
3 action
4 sade
;
proc sql;
create table want as
select table1.*
,table2.des
from table1, table2
where table1.cat=table2.id;
quit;
proc print data=want;run;
Do like this
data table1;
input Cat Name $10.;
datalines;
1 zer
4 tez
3 dgr
1 ffz
1 fzgtjt
2 pojn
2 fj
3 kfi
3 ndonz
;
data table2;
input id des $10.;
datalines;
1 com
2 the
3 action
4 sade
;
proc sql;
create table want as
select table1.*
,table2.des
from table1, table2
where table1.cat=table2.id;
quit;
proc print data=want;run;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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: