Merge datasets with unlike variable names
Saturday, May 3, 2008
Jared in Programming, SAS

Here is an example of merging datasets with Unlike variable names:

Data  DS1;
INPUT A $ B $ C $ ;
Cards ;
Small Tike Red
Med Bike Blue
Large Bike Red
;

Data DS2 ;
INPUT X $ Y $ Z $ ;
Cards ;
Small 10.99 1yr
Small 20.99 2yr
Large 50.00 1yr
;

run;

proc sql;
create table AllDS as
 select coalesce(ds1.a,ds2.x) as ax, b, c, y, z
  from ds1 full join ds2
  on ds1.a = ds2.x
  order by ax desc;
quit;

Code is also available on my Snippet Code repository.

Kudos to the guys on the SAS google group thread for coming up with this solution. 

Article originally appeared on jaredprins (http://jaredprins.squarespace.com/).
See website for complete article licensing information.