BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
shellp55
Quartz | Level 8

Hello

 

I wish to create a readmit report that shows if a patient is readmitted within 30 days.  But if there is more than one readmit, I want the program to pick the first and move on because that readmit then becomes the index case for the next readmit.  Below is my code:

 

data grp1;
input @1  chartno 	$5.
	  @6  regn  	$4.
	  @10 regdate   date9. 
	  @19 dispdate   date9.
	  
;
cards;
11111100107Apr201807Apr2018
22222200108Apr201808Apr2018
33333300108Apr201808Apr2018
11111100210Apr201810Apr2018
11111100312Apr201810Apr2018
11111100414Apr201814Apr2018
run; 

data grp2;
input @1  chartno 	$5.
	  @6  regn  	$4.
	  @10 regdate   date9. 
	  @19 dispdate   date9.
;
cards;
11111100107Apr201807Apr2018
22222200108Apr201808Apr2018
33333300108Apr201808Apr2018
11111100210Apr201810Apr2018
11111100312Apr201810Apr2018
11111100414Apr201814Apr2018
run; 

proc sort data=grp1;by chartno regdate;run;
proc sort data=grp2;by chartno regdate;run;

proc sql;
create table readm as 
select a.*,
b.regn as R_acctno,
b.regdate as R_regdate,
b.dispdate as R_dispdate
from grp1 as a left outer join grp2 as b
on a.chartno=b.chartno
where a.regn ne b.regn and
a.regdate lt b.regdate and 0 <= (b.regdate - a.dispdate) <= 7;
quit;

data readmits;
set readm;

format regdate dispdate r_regdate r_dispdate mmddyy10.;
run;

The cases from grp1 will be referenced as "index cases" and from grp2 would be the readmits.  So from the above, registration 1002 would be the first readmit for patient 11111 but it uses registration 1001 2 more times citing readmissions that do meet the criteria but I only want to show once.  I know I can write another piece of code to get the first index case but I wanted to know if the criteria can be written into what is there or another way altogether.  Thanks for any and all input. 

1 ACCEPTED SOLUTION

Accepted Solutions
shellp55
Quartz | Level 8

Thanks ChrisNZ, that will work.

 

I actually found an error in my cards as regn 1002 should have the regdate and dispdate be the same.  

 

I also found a different program to use for the readmits that meets my needs.   It is based on SAS paper 1622-2014 from Sarfaraz and Fen of UMWA.

proc sort data=grp1;by chartno regn;run;
data solution1;
set grp1;
by chartno regn;
ref_date=lag(dispdate);
format ref_date regdate dispdate yymmdd10.;
label ref_date="Reference Date";
gap=regdate-ref_date;

if first.chartno then do;
ref_date = .;
gap=.;
tag=.;
readmissions=.;
end;

if 0<=gap<=30 then tag=1;
readmissions+tag;

if tag gt 0 then output;
run;

View solution in original post

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

Like this?

proc sql;
create table readm as 
select a.*
      ,b.regn     as R_acctno  
      ,b.regdate  as R_regdate   format= date9.
      ,b.dispdate as R_dispdate  format= date9.
from grp1 as a left outer join grp2 as b
on a.chartno=b.chartno
where a.regn ne b.regn 
  and a.regdate lt b.regdate 
  and 0 <= (b.regdate - a.dispdate) <= 7
group by chartno, regdate
having R_regdate=min(R_regdate);
quit;
chartno regn regdate dispdate R_acctno R_regdate R_dispdate
11111 1001 07APR2018 07APR2018 1002 10APR2018 10APR2018
11111 1002 10APR2018 10APR2018 1003 12APR2018 10APR2018
11111 1003 12APR2018 10APR2018 1004 14APR2018 14APR2018

 

shellp55
Quartz | Level 8

Thanks ChrisNZ, that will work.

 

I actually found an error in my cards as regn 1002 should have the regdate and dispdate be the same.  

 

I also found a different program to use for the readmits that meets my needs.   It is based on SAS paper 1622-2014 from Sarfaraz and Fen of UMWA.

proc sort data=grp1;by chartno regn;run;
data solution1;
set grp1;
by chartno regn;
ref_date=lag(dispdate);
format ref_date regdate dispdate yymmdd10.;
label ref_date="Reference Date";
gap=regdate-ref_date;

if first.chartno then do;
ref_date = .;
gap=.;
tag=.;
readmissions=.;
end;

if 0<=gap<=30 then tag=1;
readmissions+tag;

if tag gt 0 then output;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 507 views
  • 0 likes
  • 2 in conversation