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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.