Open ManytoMany left.csv 

Open ManytoMany right.csv

ManytoMany left.csv preview

ManytoMany right.csv preview

*To import the data;

proc import datafile = 'C:/ManytoMany left.csv' out = l_data

dbms = csv replace;

getnames = yes;

run;

proc import datafile = 'C:/ManytoMany right.csv' out = r_data

dbms = csv replace;

getnames = yes;

run;

The data step does not produce the correct results for a many to many merge.

The SAS code will compile without producing an error.

* Refer to l_data as dataset a and r_data as dataset b;

* Use the Key variable from r_data as the Key to join;

* Select the Veggies variable from l_data and Fruits from r_data;

proc sql;

create table sql_outer_right as

select b.Key as Key, a.Veggies, b.Fruits

from l_data a right join r_data b

on a.Key = b.Key

;

quit;

Example data

Functions referenced:

proc import

proc sql: join

More information:

data step: merge vs proc sql: join

--- The End ---