Hi SAS Experts, I am trying to calculate readmissions within 30days post first MS diagnosis based on the following conditions 1) Discharge date is not the same as the index admission date. For instance, 2JAN20 cannot be used as index admission because patients was discharged on same day. 2) Index admission date is used once for patients with multiple readmissions Specifically, I would like to identify: 1) Readmissions within 30 days as a binary variable yes=1 and no=0 2) For each patient, calculate the number of readmissions that occur within 30 days. 3) For readmissions meeting the "within" 30 day readmission criteria, identify the setting they were readmitted to 4) Gap: the gap between the current admission date and the immediate previous discharge date I have provided a sample data below and desired output. In the data, MS diagnosis is named MSflag and coded 1. Claimstartdate is the first date of the MS claim (in most cases is the same as admission date but in some cases its not, hence the interest in readmission post first MS flag). Thank you data WORK.IMPORT2; infile datalines dsd truncover; input ID:BEST. Claimstartdate:DATE9. Admitdate:DATE9. Dischargedate:DATE9. MSFlag:BEST. Setting:$4.; format ID BEST. Claimstartdate DATE9. Admitdate DATE9. Dischargedate DATE9. MSFlag BEST.; label ID="ID" Claimstartdate="Claimstartdate" Admitdate="Admitdate" Dischargedate="Dischargedate" MSFlag="MSFlag" Setting="Setting"; datalines; 1 26APR2020 26APR2020 28APR2020 1 IP 1 16JUN2020 16JUN2020 28APR2020 1 SNF 2 02JAN2020 02JAN2020 02JAN2020 1 IP 2 04FEB2020 04FEB2020 10FEB2020 1 IP 2 15FEB2020 18JUN2020 15AUG2020 1 IP 3 02JAN2020 02JAN2020 22FEB2020 1 Home 3 15NOV2020 15NOV2020 20DEC2020 1 ER 4 04MAR2020 04MAR2020 14MAY2020 1 ER 5 26AUG2020 26AUG2020 13SEP2020 1 Home 5 15SEP2020 15SEP2020 20NOV2020 1 ER 6 01JAN2020 05JAN2020 08JAN2020 1 IP 6 11JAN2020 12JAN2020 18JAN2020 1 ER 6 05JUN2020 05JUN2020 15JUN2020 1 IP 6 19JUN2020 19JUN2020 05JUL2020 1 SNF 6 15SEP2020 15SEP2020 25SEP2020 1 IP 6 01NOV2020 01NOV2020 05NOV2020 1 Home 7 06MAR2020 06MAR2020 09MAR2020 1 IP 8 02JAN2020 02JAN2020 08JAN2020 1 IP 9 16JUL2020 19JUL2020 20JUL2020 1 SNF 10 01AUG2020 10AUG2020 22AUG2020 1 IP 11 26OCT2020 26OCT2020 30OCT2020 1 IP 12 21FEB2020 21FEB2020 24FEB2020 1 IP 12 27FEB2020 27FEB2020 25JUN2020 1 SNF 13 11JAN2020 11JAN2020 18JAN2020 1 IP 13 20MAR2020 20MAR2020 26MAR2020 1 IP 13 28MAR2020 28MAR2020 10JUN2020 1 IP 13 15JUN2020 15JUN2020 27DEC2020 1 SNF 14 14MAR2020 14MAR2020 18MAR2020 1 IP 15 11SEP2020 12SEP2020 22SEP2020 1 IP 16 10FEB2020 10FEB2020 11FEB2020 1 IP 16 15FEB2020 15FEB2020 04MAY2020 1 HSPC ;;;; ID Claim_start_date Admit_date Discharge_date MS Flag Setting Readmitted Within 30 days No of Readmissions Setting Readmiited to GAP Explanation 2 2-Jan-20 2-Jan-20 2-Jan-20 1 IP No . . . Not index admission date beacause patient was discharged on same day 2 4-Feb-20 4-Feb-20 10-Feb-20 1 IP No . . 33 2 15-Feb-20 18-Jun-20 15-Aug-20 1 IP Yes 1 IP 129 3 2-Jan-20 2-Jan-20 22-Feb-20 1 Home No . . . 3 15-Nov-20 15-Nov-20 20-Dec-20 1 ER No . . 267 4 4-Mar-20 4-Mar-20 14-May-20 1 ER No . . . 5 26-Aug-20 26-Aug-20 13-Sep-20 1 Home No . . . 5 15-Sep-20 15-Sep-20 20-Nov-20 1 ER Yes 1 ER 2 6 1-Jan-20 5-Jan-20 8-Jan-20 1 IP No . . . 6 11-Jan-20 12-Jan-20 18-Jan-20 1 ER Yes 1 ER 4 6 5-Jun-20 5-Jun-20 15-Jun-20 1 IP No 1 . 139 6 19-Jun-20 19-Jun-20 5-Jul-20 1 SNF Yes 2 SNF 4 6 15-Sep-20 15-Sep-20 25-Sep-20 1 IP No 2 . 72 6 1-Nov-20 1-Nov-20 5-Nov-20 1 Home No 2 . 37 7 6-Mar-20 6-Mar-20 9-Mar-20 1 IP No . . . 8 2-Jan-20 2-Jan-20 8-Jan-20 1 IP No . . . 9 16-Jul-20 19-Jul-20 20-Jul-20 1 SNF No . . . 10 1-Aug-20 10-Aug-20 22-Aug-20 1 IP No . . . 11 26-Oct-20 26-Oct-20 30-Oct-20 1 IP No . . . 12 21-Feb-20 21-Feb-20 24-Feb-20 1 IP No . . . 12 27-Feb-20 27-Feb-20 25-Jun-20 1 SNF Yes 1 SNF 3 13 11-Jan-20 11-Jan-20 18-Jan-20 1 IP No . . . 13 20-Mar-20 20-Mar-20 26-Mar-20 1 IP No . . 62 13 28-Mar-20 28-Mar-20 10-Jun-20 1 IP Yes 1 IP 2 13 15-Jun-20 15-Jun-20 27-Dec-20 1 SNF Yes 2 SNF 5 14 14-Mar-20 14-Mar-20 18-Mar-20 1 IP No . . . 15 11-Sep-20 12-Sep-20 22-Sep-20 1 IP No . . . 16 10-Feb-20 10-Feb-20 11-Feb-20 1 IP no . . . 16 15-Feb-20 15-Feb-20 4-May-20 1 HSPC Yes 1 HSPC 4
... View more