Applying conditions in outer joins is often tricky. The starting point is always a cartesian product. Then join conditions are applied. Then WHERE conditions do further subsetting. Not necessarily what the programmer expected. You'll get your expected result by applying a WHERE condition first:
TITLE 'Self Left Join';
PROC SQL;
SELECT t1.student_id
,t1.grade AS calc1_grade
,t2.grade AS calc2_grade
FROM (select * from class_grades where class = 'MTH101') as t1
LEFT JOIN (select * from class_grades where class = 'MTH102') as t2
ON t1.student_id = t2.student_id;
QUIT;
... View more