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!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 660 views
  • 0 likes
  • 2 in conversation