Got it--thank you for the explanation. I modified the code accordingly:
proc sql;
create table enroll_range as
select id
,min(enroll_dt) as min_enroll_dt format MMDDYY10.
,max(enroll_dt) as max_enroll_dt format MMDDYY10.
from enroll1
group by id;
quit;
proc sql;
create table want as
select a.id
,a.in_date
,a.out_date
,case
when e.min_enroll_dt <= a.out_date <= intnx('month', e.max_enroll_dt, 0, 'e')
then 'YES'
else 'NO'
end as ELIG_ON_OUT_DATE
,case
when intnx('day', a.out_date, 30) <= intnx('month', e.max_enroll_dt, 0, 'e')
then 'YES'
else 'NO'
end as ELIG_ON_30_DAYS_AFTER_OUT_DATE
,case
when calculated elig_on_out_date = 'YES' and calculated elig_on_30_days_after_out_date = 'YES'
then 'YES'
else 'NO'
end as QUALIFIED
from activity1 a
left join enroll_range e
on a.id = e.id;
quit;
proc print; run;
Output:
... View more