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; * The in = left option creates a temporary variable, left, that indicates if the observation was originally in the left dataset; * The if left statement, keeps only observations where left = 1; data outer_left; merge l_data(in = left) r_data(in = right); by Key; if left; run; |
Option 2
* Datasets do not need to be previously sorted; * Refer to l_data as dataset a and r_data as dataset b; * Select all variables from l_data and the Fruits variable from r_data; proc sql; create table sql_outer_left as select a.*, b.fruits from l_data a left join r_data b on a.Key = b.Key ; quit; |
Functions referenced:
More information:
data step: merge vs proc sql: join
--- The End ---