BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
cheroij
Calcite | Level 5

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.

cheroij_0-1728091095106.png

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
;;;;
 
IDClaim_start_dateAdmit_dateDischarge_dateMS FlagSettingReadmitted Within 30 daysNo of ReadmissionsSetting Readmiited toGAPExplanation
22-Jan-202-Jan-202-Jan-201IPNo...Not index admission date beacause patient was discharged on same day
24-Feb-204-Feb-2010-Feb-201IPNo..33 
215-Feb-2018-Jun-2015-Aug-201IPYes1IP129 
32-Jan-202-Jan-2022-Feb-201HomeNo... 
315-Nov-2015-Nov-2020-Dec-201ERNo..267 
44-Mar-204-Mar-2014-May-201ERNo... 
526-Aug-2026-Aug-2013-Sep-201HomeNo... 
515-Sep-2015-Sep-2020-Nov-201ERYes1ER2 
61-Jan-205-Jan-208-Jan-201IPNo... 
611-Jan-2012-Jan-2018-Jan-201ERYes1ER4 
65-Jun-205-Jun-2015-Jun-201IPNo1.139 
619-Jun-2019-Jun-205-Jul-201SNFYes2SNF4 
615-Sep-2015-Sep-2025-Sep-201IPNo2.72 
61-Nov-201-Nov-205-Nov-201HomeNo2.37 
76-Mar-206-Mar-209-Mar-201IPNo... 
82-Jan-202-Jan-208-Jan-201IPNo... 
916-Jul-2019-Jul-2020-Jul-201SNFNo... 
101-Aug-2010-Aug-2022-Aug-201IPNo... 
1126-Oct-2026-Oct-2030-Oct-201IPNo... 
1221-Feb-2021-Feb-2024-Feb-201IPNo... 
1227-Feb-2027-Feb-2025-Jun-201SNFYes1SNF3 
1311-Jan-2011-Jan-2018-Jan-201IPNo... 
1320-Mar-2020-Mar-2026-Mar-201IPNo..62 
1328-Mar-2028-Mar-2010-Jun-201IPYes1IP2 
1315-Jun-2015-Jun-2027-Dec-201SNFYes2SNF5 
1414-Mar-2014-Mar-2018-Mar-201IPNo... 
1511-Sep-2012-Sep-2022-Sep-201IPNo... 
1610-Feb-2010-Feb-2011-Feb-201IPno... 
1615-Feb-2015-Feb-204-May-201HSPCYes1HSPC4 
 
 
1 ACCEPTED SOLUTION

Accepted Solutions
JOL
SAS Employee JOL
SAS Employee

data WORK.IMPORT2;
infile datalines;
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
;
run;

 

 

data test;
set import2;
by id; /* Creates two hidden variables first.id and last.id that can be used for group processing */
ad2 = lag(admitdate);/* LAG functions calculates the previous value */
dis2= lag(dischargedate);

if dischargedate = admitdate then
explanation = "Discharged same day";

if first.id = 0 then
do;
readmit_d = admitdate - ad2;
gap = admitdate - dis2;

if 0<= readmit_d < 30 then
do;
readmit_f='Yes';
Readmit_Setting = Setting;
end;
else readmit_f='No';
end;

format ad2 dis2 date9.;
run;

 

 

/* Use PROC FREQ to create report with counts of re-admissions within 30 days */
proc freq data=test;
tables id*readmit_f / list nocum nopercent;
run;

 

View solution in original post

2 REPLIES 2
JOL
SAS Employee JOL
SAS Employee

data WORK.IMPORT2;
infile datalines;
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
;
run;

 

 

data test;
set import2;
by id; /* Creates two hidden variables first.id and last.id that can be used for group processing */
ad2 = lag(admitdate);/* LAG functions calculates the previous value */
dis2= lag(dischargedate);

if dischargedate = admitdate then
explanation = "Discharged same day";

if first.id = 0 then
do;
readmit_d = admitdate - ad2;
gap = admitdate - dis2;

if 0<= readmit_d < 30 then
do;
readmit_f='Yes';
Readmit_Setting = Setting;
end;
else readmit_f='No';
end;

format ad2 dis2 date9.;
run;

 

 

/* Use PROC FREQ to create report with counts of re-admissions within 30 days */
proc freq data=test;
tables id*readmit_f / list nocum nopercent;
run;

 

cheroij
Calcite | Level 5

Thank you very much😊 It worked perfectly, albeit with minor modifications

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 271 views
  • 1 like
  • 2 in conversation