You might want to think about your definition of the alias A.
(a.date-a.day)as start_dt format YYMMDD10., b.SECTID
from work.ADDREGDAY as a left join
(select distinct TERMS_ID, SECTID from work.addregday where TERMS_ID="&TERMS_ID" and SECTID is not null)b
on a.TERMS_ID=b.TERMS_ID where a.TERMS_ID="&Terms_ID") as drv
left join
(select * from work.addregday where TERMS_ID="&TERMS_ID") as a
on drv.day=a.day and drv.SECTID=a.SECTID;
quit;
With more than one A are you sure that the CASE statement is using the right one? If both A have a variable in common but different types that could be an issue.
Back out the multiple joins to just the variables in the Case statements and test. I am not sure why you bothered to point out those variables, the Case statement When clauses are using Credithours and Seatcount. Those would be variables to look at.
Please consider formatting your code as it is very hard to follow. Paste code into a code box opened on the forum with the "running man" or </> icons that appear above the message windows. Log text should go into a text box opened with the </> icon.
... View more