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

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:

CatName
1zer
4tez
3dgr
1ffz
1fzgtjt
2pojn
2fj
3kfi
3ndonz

 

Table 2

 

iddes
1com
2the
3action
4sade

 

And the table that I receive

 

CatNamedes
1zercom
4tezsade
3dgraction
1ffzcom
1fzgtjtcom
2pojnthe
2fjthe
3kfiaction
3ndonzaction

 

Thanks for your help

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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;

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

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;
WilliamB
Obsidian | Level 7
Great thank you very much!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 2 replies
  • 1088 views
  • 0 likes
  • 2 in conversation