Merge two data sets

Reply
Occasional Contributor
Posts: 9

Merge two data sets

I have two data sets that look like this

1)

========================================

ColumnA     ||  ColumnB     ||  ColumnC     ||  Column D

========================================

     x                    x                    x                    .

     y                    y                    .                    y

     z                    z                    .                    z

and 2)....

========================================

ColumnA     ||  ColumnB     ||  ColumnC     ||  Column D

========================================

     x                    x                    .                    x

     y                    y                    y                    .

     z                    z                    z                    .

I have missing values in the last two columns in each data set.  I want to merge (1-to-1) the two data sets and I want the values from table 1 to go in the cells with the missing values in table 2 and the values in table 2 to go into the cells with missing values in table 1.  I tried to use MERGE but this one-to-one match replaces all columns with just the columns from the 2nd data set which just ends up being the same thing.  Any ideas?

Thank you.

-john

Regular Contributor
Posts: 168

Re: Merge two data sets

Posted in reply to GoBrewers14

Hi GoBrewers,

May be some one can come up with good one, but you can start with this

proc sql;

create table want as

select a.cola,a.colb,coalesce(a.colc,b.colc) as colc,coalesce(a.cold,b.cold) as cold

from temp1 as a inner join temp2 as b

on a.cola=b.cola & a.colb=b.colb;

quit;

Thanks

Sam

Ask a Question
Discussion stats
  • 1 reply
  • 125 views
  • 0 likes
  • 2 in conversation