<?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: Find individuals with multiple encounters and same diagnosis on a rolling basis in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-individuals-with-multiple-encounters-and-same-diagnosis-on/m-p/240115#M308835</link>
    <description>&lt;P&gt;Couldn't do any testing, but this should be close:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data diag140106_350;
set caper140106_350xx_sort;
array d{*} dx1-dx5;
do i = 1 to dim(d);
    diag = d{i};
    if diag in (/* list of required diagnosis goes here */) then output;
    end;
keep patssn encdate1 diag;
run;

proc sql;
create table diag3all as
select 
    a.patssn, 
    a.diag,
    a.encDate1,
    b.encDate1 as otherDate1,
    count(distinct b.encDate1) + 1 as nbDiag
from 
    diag140106_350 as a inner join
    diag140106_350 as b 
        on 
            a.patssn = b.patssn and 
            a.diag = b.diag and 
            a.encDate1 &amp;lt; b.encDate1 and 
            intck("month", a.encDate1, b.encDate1, "continuous") &amp;lt;= 6
group by a.patssn, a.diag, a.encDate1
having count(distinct b.encDate1) + 1 &amp;gt;= 3;

create table diag3 as
select * 
from diag3all 
group by patssn, diag 
having nbDiag = max(nbDiag);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 18 Dec 2015 21:24:17 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2015-12-18T21:24:17Z</dc:date>
    <item>
      <title>Find individuals with multiple encounters and same diagnosis on a rolling basis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-individuals-with-multiple-encounters-and-same-diagnosis-on/m-p/240097#M308834</link>
      <description>&lt;P&gt;I'm attempting to find individuals with at least 3 medical encounters during a 6-month period with the same specified diagnosis codes&amp;nbsp;in one of the first&amp;nbsp;5 diagnosis fields (dx1-dx5). One of my colleagues had code to do the same thing but only needed 2 medical encounters; I've attempted to adapt it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I first created a data set that included only individuals who had the desired diagnosis in one of the first 5 diagnosis fields&amp;nbsp;and used that for the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;create&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;table&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; caper140106_350_obs (drop=lo hi) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;select&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; a.patssn, a.edipn, a.appttype, a.encdate1 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; encdate1_check, a.nobs &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;nobs_check, a.dx1 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; dx1_check, a.dx2 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; dx2_check, a.dx3 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; dx3_check,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;a.dx4 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; dx4_check, a.dx5 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; dx5_check,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;b.encdate1 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; encdate1_plus, b.nobs &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; nobs_plus, b.dx1 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; dx1_plus,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;b.dx2 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; dx2_plus, b.dx3 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; dx3_plus, b.dx4 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; dx4_plus, b.dx5 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; dx5_plus,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;c.encdate1, c.nobs, c.dx1, c.dx3, c.dx4, c.dx5,&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;intnx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New"&gt;&lt;FONT color="#800080" face="Courier New"&gt;'month'&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;,a.encdate1,-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;6&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; lo, intnx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New"&gt;&lt;FONT color="#800080" face="Courier New"&gt;'month'&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;,a.encdate1,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New"&gt;&lt;FONT color="#008080" face="Courier New"&gt;6&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; hi,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;catx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New"&gt;&lt;FONT color="#800080" face="Courier New"&gt;''&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;,min(a.encdate1,c.encdate1), max(a.encdate1,c.encdate1))&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; minmax&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; caper140106_350xx_sort &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; a, caper140106_350xx_sort &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; b,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;caper140106_350xx_sort &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; c&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;where&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; a.patssn=b.patssn=c.patssn &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;and&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; (b.encdate1 &amp;amp; c.encdate1 between&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;calculated lo &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;and&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; calculated hi) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;and&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; a.nobs^=b.nobs^=c.nobs&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;order&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; patssn, encdate1_plus;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;FONT color="#000080" face="Courier New"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;It runs, and I get results that appear to be correct, but I'm not confident that I actually have what I need. I started with 814 rows and the results gave me 79,278 rows. When I deduped the individuals, I end up with 148 people (probably reasonable).&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;Secondary question: I have more than 25 specfic diagnosis codes that I need to do this for. Do I need to create a data set for each of the diagnoses first and then find individuals with multiple encounters or is there a way to find folks with the multiple encounters and then pull my diagnosis codes?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;I really appreciate any help with this.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2015 20:12:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-individuals-with-multiple-encounters-and-same-diagnosis-on/m-p/240097#M308834</guid>
      <dc:creator>janet0102</dc:creator>
      <dc:date>2015-12-18T20:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: Find individuals with multiple encounters and same diagnosis on a rolling basis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-individuals-with-multiple-encounters-and-same-diagnosis-on/m-p/240115#M308835</link>
      <description>&lt;P&gt;Couldn't do any testing, but this should be close:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data diag140106_350;
set caper140106_350xx_sort;
array d{*} dx1-dx5;
do i = 1 to dim(d);
    diag = d{i};
    if diag in (/* list of required diagnosis goes here */) then output;
    end;
keep patssn encdate1 diag;
run;

proc sql;
create table diag3all as
select 
    a.patssn, 
    a.diag,
    a.encDate1,
    b.encDate1 as otherDate1,
    count(distinct b.encDate1) + 1 as nbDiag
from 
    diag140106_350 as a inner join
    diag140106_350 as b 
        on 
            a.patssn = b.patssn and 
            a.diag = b.diag and 
            a.encDate1 &amp;lt; b.encDate1 and 
            intck("month", a.encDate1, b.encDate1, "continuous") &amp;lt;= 6
group by a.patssn, a.diag, a.encDate1
having count(distinct b.encDate1) + 1 &amp;gt;= 3;

create table diag3 as
select * 
from diag3all 
group by patssn, diag 
having nbDiag = max(nbDiag);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Dec 2015 21:24:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-individuals-with-multiple-encounters-and-same-diagnosis-on/m-p/240115#M308835</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-12-18T21:24:17Z</dc:date>
    </item>
  </channel>
</rss>

