@HB the first entry for ID 1 has an encounter date more than 6 months before the index date. Therefore, the two dates for this observation are out of the specified range and would not count. Does this makes sense? I currently have the following code below. Do you think this is right? proc sql;
select Patient_ID,
sum((intnx('month',index_date,-6,'s')<=encounter_date<=index_date) and
(encounter_type='Telemedicine' or outpatient='Yes') ) as New_var
from have
group by Patient_ID ;
quit;
... View more