<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Code Not Picking Next Visit as Readmit in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Code-Not-Picking-Next-Visit-as-Readmit/m-p/557111#M155266</link>
    <description>&lt;P&gt;Thanks ChrisNZ, that will work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I actually found an error in my cards as regn 1002 should have the regdate and dispdate be the same.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also found a different program to use for the readmits that meets my needs.&amp;nbsp; &amp;nbsp;It is based on SAS paper 1622-2014 from Sarfaraz and Fen of UMWA.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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&amp;lt;=gap&amp;lt;=30 then tag=1;
readmissions+tag;

if tag gt 0 then output;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 08 May 2019 13:54:21 GMT</pubDate>
    <dc:creator>shellp55</dc:creator>
    <dc:date>2019-05-08T13:54:21Z</dc:date>
    <item>
      <title>Code Not Picking Next Visit as Readmit</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-Not-Picking-Next-Visit-as-Readmit/m-p/556496#M155016</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wish to create a readmit report that shows if a patient is readmitted within 30 days.&amp;nbsp; But if there is more than one readmit, I want the program&amp;nbsp;to pick the first and move on because that readmit then becomes the index case for the next readmit.&amp;nbsp; Below is my code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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 &amp;lt;= (b.regdate - a.dispdate) &amp;lt;= 7;
quit;

data readmits;
set readm;

format regdate dispdate r_regdate r_dispdate mmddyy10.;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The cases from grp1 will be referenced as "index cases" and from grp2 would be the readmits.&amp;nbsp; 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.&amp;nbsp; 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.&amp;nbsp; Thanks for any and all input.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2019 17:22:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-Not-Picking-Next-Visit-as-Readmit/m-p/556496#M155016</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2019-05-06T17:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: Code Not Picking Next Visit as Readmit</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-Not-Picking-Next-Visit-as-Readmit/m-p/556977#M155220</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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 &amp;lt;= (b.regdate - a.dispdate) &amp;lt;= 7
group by chartno, regdate
having R_regdate=min(R_regdate);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.READMITS" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;chartno&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;regn&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;regdate&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;dispdate&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;R_acctno&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;R_regdate&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;R_dispdate&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;11111&lt;/TD&gt;
&lt;TD class="l data"&gt;1001&lt;/TD&gt;
&lt;TD class="r data"&gt;07APR2018&lt;/TD&gt;
&lt;TD class="r data"&gt;07APR2018&lt;/TD&gt;
&lt;TD class="l data"&gt;1002&lt;/TD&gt;
&lt;TD class="r data"&gt;10APR2018&lt;/TD&gt;
&lt;TD class="r data"&gt;10APR2018&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;11111&lt;/TD&gt;
&lt;TD class="l data"&gt;1002&lt;/TD&gt;
&lt;TD class="r data"&gt;10APR2018&lt;/TD&gt;
&lt;TD class="r data"&gt;10APR2018&lt;/TD&gt;
&lt;TD class="l data"&gt;1003&lt;/TD&gt;
&lt;TD class="r data"&gt;12APR2018&lt;/TD&gt;
&lt;TD class="r data"&gt;10APR2018&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;11111&lt;/TD&gt;
&lt;TD class="l data"&gt;1003&lt;/TD&gt;
&lt;TD class="r data"&gt;12APR2018&lt;/TD&gt;
&lt;TD class="r data"&gt;10APR2018&lt;/TD&gt;
&lt;TD class="l data"&gt;1004&lt;/TD&gt;
&lt;TD class="r data"&gt;14APR2018&lt;/TD&gt;
&lt;TD class="r data"&gt;14APR2018&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 23:49:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-Not-Picking-Next-Visit-as-Readmit/m-p/556977#M155220</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-05-07T23:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Code Not Picking Next Visit as Readmit</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Code-Not-Picking-Next-Visit-as-Readmit/m-p/557111#M155266</link>
      <description>&lt;P&gt;Thanks ChrisNZ, that will work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I actually found an error in my cards as regn 1002 should have the regdate and dispdate be the same.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also found a different program to use for the readmits that meets my needs.&amp;nbsp; &amp;nbsp;It is based on SAS paper 1622-2014 from Sarfaraz and Fen of UMWA.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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&amp;lt;=gap&amp;lt;=30 then tag=1;
readmissions+tag;

if tag gt 0 then output;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 May 2019 13:54:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Code-Not-Picking-Next-Visit-as-Readmit/m-p/557111#M155266</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2019-05-08T13:54:21Z</dc:date>
    </item>
  </channel>
</rss>

