Here is how you could add your flags into the one step:
proc sql;
create table want as
select H1.acct_id
,min(H1.snapshot_date) as Start_Date format = date9.
,H2.Default_Date format = date9.
,case
when intck('MONTH', calculated Start_Date, H2.Default_Date, 'C') <= 12 then 1
else 0
end as Default_Flag
,H3.Writeoff_Date format = date9.
,case
when calculated Default_Flag = 1 and intck('MONTH', calculated Start_Date, Writeoff_Date, 'C') <= 60 then 1
else 0
end as Writeoff_Flag
from credit_data as H1
left join
(select acct_id
,min(snapshot_date) as Default_Date
from credit_data
where BQR = '9'
group by acct_id
) as H2
on H1.acct_id = H2.acct_id
left join
(select acct_id
,min(snapshot_date) as Writeoff_Date
from credit_data
where BQR = 'W'
group by acct_id
) as H3
on H1.acct_id = H3.acct_id
group by H1.acct_id
;
quit;
... View more