Here's how I approached it:
PROC SQL; CREATE TABLE WORK.QUERY_FOR_JAN AS SELECT t1.id, t1.className, t1.startdate, t2.id AS id1, t2.className AS className1, t2.startdate AS startdate1, t3.id AS id2, t3.className AS className2, t3.startdate AS startdate2, /* enddate */ (case when t2.startdate is missing then t1.startdate when t3.startdate is missing then t2.startdate end) FORMAT=date9. AS enddate FROM WORK.JAN t1 LEFT JOIN WORK.FEB t2 ON (t1.id = t2.id) AND (t1.className = t2.className) LEFT JOIN WORK.MAR t3 ON (t2.id = t3.id) AND (t2.className = t3.className); QUIT;
... View more