I am not sure what your enrollment data looks like but if you only want the number of enrollment days in the diagnosis year then you need to get the beginning and ending enrollment period for that particular year. data temp; format enroll_start_date enroll_end_date diag_date mmddyy10.; enroll_start_date = '01mar2010'd; enroll_end_date = '31may2013'd; diag_date = '12apr2010'd; output; diag_date = '05jan2011'd; output; run; data temp; set temp; format yr_enroll_start_date yr_enroll_end_date mmddyy10.; /*****************************************************************/ /* create yr enrollment information for the yr of the diag */ /******************************************************************/ /* if the enrollment end date is after the end of the year of the diag, then set the yr enrollment end date to the last day of the diag year */ if year(enroll_end_date) > year(diag_date) then yr_enroll_end_date = intnx('year', diag_date, 0, 'ending'); else yr_enroll_end_date = enroll_end_date; /* if the enrollment start date is prior to the year of the diag, then set the yr enrollment start date to the beginning of the diag year */ if year(enroll_start_date) < year(diag_date) then yr_enroll_start_date = intnx('year',diag_date,0,'beginning'); else yr_enroll_start_date = enroll_start_date; days = yr_enroll_end_date - yr_enroll_start_date + 1; if days >= 300 then valid_enrollment = 'Y'; else valid_enrollment = 'N'; run;
... View more