data have1;
var1=1;
do id=1,3,6;
output;
end;
run;
data have2;
var2=1;
do id=1 to 5;
output;
end;
run;
proc sql;
select t1.id, t1.var1, t2.var2
from have1 t1 left join have2 t2
on t1.id=t2.id
;
quit;
proc sql;
select t1.id, t1.var1, t2.var2
from have2 t2 right join have1 t1
on t1.id=t2.id
;
quit;
Keep all rows from the left side as opposed to keep all rows from the right side. But if you have a left join formulated and then switch to a right join and also switch your source tables accordingly then the result will be the same.
data have1;
var1=1;
do id=1,3,6;
output;
end;
run;
data have2;
var2=1;
do id=1 to 5;
output;
end;
run;
proc sql;
select t1.id, t1.var1, t2.var2
from have1 t1 left join have2 t2
on t1.id=t2.id
;
quit;
proc sql;
select t1.id, t1.var1, t2.var2
from have2 t2 right join have1 t1
on t1.id=t2.id
;
quit;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Registration is open
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss. Register now and save with the early bird rate—just $795!