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

Hi. 

I have two identical tables and I want to add the last column of the second table to the first table. But I want to change the variable names.

How do I program it?

 

Table 1

Group Setting Value
1 a 25
2 b 30
3 c 45

 

Table 2

Group Setting Value
1 a 48
2 b 59
3 c 35

 

Final output

Group Setting Value 1 Value 2
1 a 25 48
2 b 30 59
3 c 45 35

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User
proc sql;
create table want as
  select
    coalesce(t1.group,t2.group) as group,
    coalesce(t1.setting,t2.setting) as setting,
    t1.value as value_1,
    t2.value as value_2
  from table1 t1
  full join table2 t2
  on t1.group = t2.group and t1.setting = t2.setting  
;
quit;

View solution in original post

3 REPLIES 3
yoyong555
Obsidian | Level 7
Thank you. If I use PROC SQL, how will the program look like?
Kurt_Bremser
Super User
proc sql;
create table want as
  select
    coalesce(t1.group,t2.group) as group,
    coalesce(t1.setting,t2.setting) as setting,
    t1.value as value_1,
    t2.value as value_2
  from table1 t1
  full join table2 t2
  on t1.group = t2.group and t1.setting = t2.setting  
;
quit;

SAS Innovate 2025: Call for Content

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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