BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

Depending on how you look at it - yes.

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;

Patrick_0-1702260997762.png

 

View solution in original post

3 REPLIES 3
Patrick
Opal | Level 21

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.

cosmid
Lapis Lazuli | Level 10
So they are essentially the same?
Patrick
Opal | Level 21

Depending on how you look at it - yes.

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;

Patrick_0-1702260997762.png