Open 1to1 left.csv | Open 1to1 right.csv |
*To import the data;
proc import datafile = 'C:/1to1 left.csv' out = l_data dbms = csv replace;
getnames = yes;
run;
proc import datafile = 'C:/1to1 right.csv' out = r_data dbms = csv replace;
getnames = yes;
run;
Option 1: Merge using a data step
* Datasets MUST be sorted on Key variable prior to merging; proc sort data = l_data; by Key; run; proc sort data = r_data; by Key; run; data outer_full; merge l_data r_data; by Key; run; |
Option 2: Merge using proc sql
* Datasets do not need to be previously sorted; * Refer to l_data as dataset a and r_data as dataset b; * The coalesce function is used to create the Key to join on; * Select the Veggies variable from l_data and Fruits from r_data; proc sql; create table sql_outer_full as select coalesce(a.Key, b.Key) as Key, a.Veggies, b.Fruits from l_data a full join r_data b on a.Key = b.Key ; quit; |
Functions referenced:
More information:
data step: merge vs proc sql: join
--- The End ---