Hi guys,
suppose to have the following:
data DB;
input ID :$20. Admission :date09. Discharge :date09.;
format Admission date9. Discharge date9.;
cards;
0001 13JAN2017 25JAN2017
0001 27JAN2017 07MAR2017
0001 11MAR2017 16MAY2017
0001 30JAN2019 04MAR2019
0002 11SEP2014 15SEP2014
0002 28DEC2014 03JAN2015
0002 05JAN2015 12MAR2015
;
Now I want to calculate -14 days from Admission and +30days from Discharge but: if the days discharge-next admission is < 44 days then insert a missing.
The desired output is the following:
data DB1;
input ID :$20. Admission :date09. Discharge :date09. Limit1 :date09. Limit2 :date09.;
format Admission date9. Discharge date9. Limit1 date9. Limit2 date9.;
cards;
0001 13JAN2017 25JAN2017 30DEC2016 .
0001 27JAN2017 07MAR2017 . .
0001 11MAR2017 16MAY2017 . 15JUN2017
0001 30JAN2019 04MAR2019 16JAN2019 03APR2019
0002 11SEP2014 15SEP2014 28AUG2014 15OCT2014
0002 28DEC2014 03JAN2015 14DEC2014 .
0002 05JAN2015 12MAR2015 . 11APR2015
;
For example, for ID 0001 since there are only 2 days between 25JAN2017 and 27JAN2017 if I count 25JAN+30 or 27JAN -14 some overlap will occur. In this (and similar) case because of this overlap a missing should be inserted meaning that no considerations can be done. For ID= 0001 this happens for 3 sets of adm-disch (first 3 rows) but this is completely variable. In some cases there can be 5, 6 or 2 sets of dates that are hospitalizations that occur closely.
Can anyone help me please?