<?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: Identifying enrolids with two claims for specific dx code, at least one month apart in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424436#M104517</link>
    <description>Sorry it’s not clear! The substitution code you work is closer to what I&lt;BR /&gt;think I may want. Is nextobs a SAS function? Basically want to say to SAS&lt;BR /&gt;“find me the next observation where the flag =1 and tell me if it’s more&lt;BR /&gt;than a month apart”.&lt;BR /&gt;&lt;BR /&gt;Thanks!</description>
    <pubDate>Tue, 02 Jan 2018 20:21:56 GMT</pubDate>
    <dc:creator>cdubs</dc:creator>
    <dc:date>2018-01-02T20:21:56Z</dc:date>
    <item>
      <title>Identifying enrolids with two claims for specific dx code, at least one month apart?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424427#M104510</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am selecting a sample of enrolid from&amp;nbsp;insurance data that has two claims for&amp;nbsp;a set of dx codes, and the claims are at least one month apart.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was thinking of something along the lines of&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dx_list='1234', '1356';

/*First step*/
data flag_dx;&amp;nbsp;
set have;
if (dx1 in &amp;amp;dx_list. or dx2 in &amp;amp;dx_list.) then dx_flag=1;
run;

/*Second step (not sure how to translate this into SAS)*/
data flag_month_apart;
set flag_dx;
if flag=1 and (intck ('month', svc_date, next obs where flag=1)&amp;gt;=1) then do;
month_flag=1;&lt;BR /&gt;end;
run;

/*Third step (generate list of enrolids with month_flag=1)*/
proc sort data=flag_month_apart nodupkey;
by enrolid; where month_flag=1;&amp;nbsp;
run;

/*Fourth step&amp;nbsp;(inner join w/ final dataset)*/
proc sql;&amp;nbsp;
create table final_patients as&amp;nbsp;
select a.*, b.*
from have as a&amp;nbsp;
flag_month_apart as b
where a.enrolid = b.enrolid;
quit;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Not sure if people have a better strategy, and/or have suggestions as to how to translate some of the above into SAS?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;UPDATE: -- example of what I have and want.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-forum-message-main"&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-right lia-quilt-column-main-right"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-right"&gt;&lt;DIV class="lia-message-body lia-component-body"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;&lt;STRONG&gt;Have:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;enrolid dx1 dx2 svcdate&amp;nbsp;&lt;/P&gt;&lt;P&gt;839571 1234 8593 8/11/2010&amp;nbsp;&lt;/P&gt;&lt;P&gt;839571 1234 8593 8/23/2010&amp;nbsp;&lt;/P&gt;&lt;P&gt;839571 1234 8593 9/15/2010&amp;nbsp;&lt;/P&gt;&lt;P&gt;958170 9381 1935 7/25/2012&amp;nbsp;&lt;/P&gt;&lt;P&gt;958170 1234 8311 9/30/2012&amp;nbsp;&lt;/P&gt;&lt;P&gt;553312 8311 1234 7/15/2012&amp;nbsp;&lt;/P&gt;&lt;P&gt;553312 8311 1234 7/21/2012&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Want&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;enrolid dx1 dx2 svcdate flag_dx flag_month_apart&lt;/P&gt;&lt;P&gt;839571 1234 8593 8/11/2010 1 .&lt;/P&gt;&lt;P&gt;839571 1234 8593 8/23/2010 1 .&lt;/P&gt;&lt;P&gt;839571 1234 8593 9/15/2010 1 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because the other ones don't have two claims for the right dx codes at least one month apart.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want only the enrolids (and all the&amp;nbsp;observations associated with them), as long as the enrolid has two+&amp;nbsp;qualifying dx codes at least one month apart...&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 02 Jan 2018 20:56:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424427#M104510</guid>
      <dc:creator>cdubs</dc:creator>
      <dc:date>2018-01-02T20:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying enrolids with two claims for specific dx code, at least one month apart?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424431#M104512</link>
      <description>&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token comment"&gt;/*Second step (not sure how to translate this into SAS)*/&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; flag_month_apart&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; flag_dx&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; flag&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; and &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;intck&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'month'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; svc_date&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; next obs &lt;SPAN class="token statement"&gt;where&lt;/SPAN&gt; flag&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; do&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
month_flag&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;is next obs name of a variable?&lt;/P&gt;&lt;P&gt;your req is not clear:&lt;/P&gt;&lt;P&gt;but is this what you want?&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; flag_month_apart&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; flag_dx&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; flag&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; and &lt;SPAN class="token function"&gt;intck&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'month'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; svc_date&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; nextobs)&amp;gt;=1 &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; month_flag&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2018 20:13:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424431#M104512</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-02T20:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying enrolids with two claims for specific dx code, at least one month apart?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424433#M104514</link>
      <description>Sorry that’s the part I think I need help with translating into SAS. the code is supposed to refer us to the next observation where dx_flag =1&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Jan 2018 20:13:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424433#M104514</guid>
      <dc:creator>cdubs</dc:creator>
      <dc:date>2018-01-02T20:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying enrolids with two claims for specific dx code, at least one month apart?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424435#M104516</link>
      <description>&lt;P&gt;Sorry I am unable to picture or imagine your data and what's coming&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2018 20:18:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424435#M104516</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-02T20:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying enrolids with two claims for specific dx code, at least one month apart</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424436#M104517</link>
      <description>Sorry it’s not clear! The substitution code you work is closer to what I&lt;BR /&gt;think I may want. Is nextobs a SAS function? Basically want to say to SAS&lt;BR /&gt;“find me the next observation where the flag =1 and tell me if it’s more&lt;BR /&gt;than a month apart”.&lt;BR /&gt;&lt;BR /&gt;Thanks!</description>
      <pubDate>Tue, 02 Jan 2018 20:21:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424436#M104517</guid>
      <dc:creator>cdubs</dc:creator>
      <dc:date>2018-01-02T20:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying enrolids with two claims for specific dx code, at least one month apart</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424437#M104518</link>
      <description>&lt;P&gt;Provide us a sample of what you HAVE and what you WANT please&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2018 20:23:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424437#M104518</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-02T20:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying enrolids with two claims for specific dx code, at least one month apart</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424442#M104519</link>
      <description>&lt;P&gt;Great idea! I should have done that.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Say that&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macroname"&gt;%let&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;dx&lt;/SPAN&gt;_list&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'1234'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'1356'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Have:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;enrolid dx1 dx2 svcdate&amp;nbsp;&lt;/P&gt;&lt;P&gt;839571 1234 8593 8/11/2010&amp;nbsp;&lt;/P&gt;&lt;P&gt;839571 1234 8593 8/23/2010&amp;nbsp;&lt;/P&gt;&lt;P&gt;839571 1234 8593 9/15/2010&amp;nbsp;&lt;/P&gt;&lt;P&gt;958170 9381 1935 7/25/2012&amp;nbsp;&lt;/P&gt;&lt;P&gt;958170 1234 8311 9/30/2012&amp;nbsp;&lt;/P&gt;&lt;P&gt;553312 8311 1234 7/15/2012&amp;nbsp;&lt;/P&gt;&lt;P&gt;553312 8311 1234 7/21/2012&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Want&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;enrolid dx1 dx2 svcdate flag_dx flag_month_apart&lt;/P&gt;&lt;P&gt;839571 1234 8593 8/11/2010 1 .&lt;/P&gt;&lt;P&gt;839571 1234 8593 8/23/2010 1 .&lt;/P&gt;&lt;P&gt;839571 1234 8593 9/15/2010 1 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because the other ones don't have two claims for the right dx codes at least one month apart.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want only the enrolids (and all the&amp;nbsp;observations associated with them), as long as the enrolid has two+&amp;nbsp;qualifying dx codes at least one month apart...&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2018 20:53:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424442#M104519</guid>
      <dc:creator>cdubs</dc:creator>
      <dc:date>2018-01-02T20:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying enrolids with two claims for specific dx code, at least one month apart</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424448#M104520</link>
      <description>&lt;P&gt;&lt;BR /&gt;data have;&lt;BR /&gt;input enrolid dx1 dx2 svcdate :mmddyy10.;&lt;BR /&gt;format svcdate mmddyy10.;&lt;BR /&gt;datalines;&lt;BR /&gt;839571 1234 8593 8/11/2010&lt;BR /&gt;839571 1234 8593 8/23/2010&lt;BR /&gt;839571 1234 8593 9/15/2010&lt;BR /&gt;958170 9381 1935 7/25/2012&lt;BR /&gt;958170 1234 8311 9/30/2012&lt;BR /&gt;553312 8311 1234 7/15/2012&lt;BR /&gt;553312 8311 1234 7/21/2012&lt;BR /&gt;;&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;by enrolid notsorted;&lt;BR /&gt;k=lag(svcdate);&lt;BR /&gt;if not first.enrolid and intck('month',k,svcdate)&amp;gt;=1 then month_flag=1;&lt;BR /&gt;drop k;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2018 21:00:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424448#M104520</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-02T21:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying enrolids with two claims for specific dx code, at least one month apart</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424461#M104523</link>
      <description>Thank you! And if I want to make sure the service date is only counted if the Dx code is correct, do I add a “where dx1 in &amp;amp;dx_list. ...” or something like that?&lt;BR /&gt;&lt;BR /&gt;(Will try once I get home)&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Jan 2018 21:53:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424461#M104523</guid>
      <dc:creator>cdubs</dc:creator>
      <dc:date>2018-01-02T21:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying enrolids with two claims for specific dx code, at least one month apart</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424462#M104524</link>
      <description>&lt;P&gt;yes you may have to add a where or IF, depending on the dx code to satisfy and process&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2018 21:54:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424462#M104524</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-02T21:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying enrolids with two claims for specific dx code, at least one month apart?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424474#M104529</link>
      <description>&lt;P&gt;Sounds like you could just take the min and max date and check if they are at least 30 days apart.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
create table want as
select enrolid
     , min(svc_date) as firstdt format=date9.
     , max(svc_date) as lastdt format=date9.
     , count(distinct svc_date) as ndates
     , count(*) as nrecords
where (dx1 in &amp;amp;dx_list. or dx2 in &amp;amp;dx_list.)
group by 1
having (calculated lastdt - calculated firstdt) &amp;gt; 30
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Jan 2018 22:44:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424474#M104529</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-01-02T22:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying enrolids with two claims for specific dx code, at least one month apart</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424496#M104539</link>
      <description>&lt;P&gt;Like so many questions in sas community, this task can be based on choosing the right type of self-interleaving.&amp;nbsp; I.e. you can pass through each ID twice, once to establish the filter (max_date-min_date&amp;gt;=1 month for qualifying DX codes), and a second time to reread, calculate individual flag values, and optionally output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
 input enrolid dx1 :$4. dx2 :$4. svcdate :mmddyy10.;
 format svcdate yymmddn8.;
datalines;
839571 1234 8593 8/11/2010 
839571 1234 8593 8/23/2010 
839571 1234 8593 9/15/2010 
958170 9381 1935 7/25/2012 
958170 1234 8311 9/30/2012 
553312 8311 1234 7/15/2012 
553312 8311 1234 7/21/2012 
run;

%let dx_list='1234', '1356';

data want (drop=range min_date);
  set have ;
  by enrolid notsorted;
  where dx1 in (&amp;amp;dx_list) or dx2 in (&amp;amp;dx_list);
  if first.enrolid then min_date=svcdate;
  retain min_date;

  if last.enrolid;
  range=intck('month',min_date,svcdate,'C');

  do until (last.enrolid);
    set have;
    by enrolid notsorted;
    flag=(1&amp;lt;= intck('month',min_date,svcdate,'C'));
    if range&amp;gt;=1 then output;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The "if last.enrolid" subsetting if allow calculation of range between min_date and max svcdate.&lt;/LI&gt;
&lt;LI&gt;After the "if last.enrolid" and range calculation is a do loop, which re-reads the same enrolid group and generate a record-by-record value for flag.&amp;nbsp; If range satisfies the filter the record is output.&lt;/LI&gt;
&lt;LI&gt;This program assume each id is physically grouped by enrolid, although not necessarily in ascending or descending order.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Wed, 03 Jan 2018 02:23:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424496#M104539</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-01-03T02:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying enrolids with two claims for specific dx code, at least one month apart?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424557#M104555</link>
      <description>&lt;P&gt;There are too many things uncertainty. If I understood correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
 input enrolid dx1 :$4. dx2 :$4. svcdate :mmddyy10.;
 format svcdate yymmddn8.;
datalines;
839571 1234 8593 8/11/2010 
839571 1234 8593 8/23/2010 
839571 1234 8593 9/15/2010 
958170 9381 1935 7/25/2012 
958170 1234 8311 9/30/2012 
553312 8311 1234 7/15/2012 
553312 8311 1234 7/21/2012 
run;

%let dx_list='1234', '1356';
proc sql;
create table id as
 select distinct enrolid from have
  where dx1 in (&amp;amp;dx_list)
   group by enrolid,dx1
    having intck('month',min(svcdate),max(svcdate),'c')&amp;gt;0
union
 select distinct enrolid from have
  where dx2 in (&amp;amp;dx_list)
   group by enrolid,dx2
    having intck('month',min(svcdate),max(svcdate),'c')&amp;gt;0 ;

create table want as
 select *
  from have
   where enrolid in (select enrolid from id);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Jan 2018 13:22:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/424557#M104555</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-01-03T13:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying enrolids with two claims for specific dx code, at least one month apart?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/431487#M106740</link>
      <description>Thank you! This works well! I modified slightly but the concept is what I ended up using &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Fri, 26 Jan 2018 23:50:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-enrolids-with-two-claims-for-specific-dx-code-at/m-p/431487#M106740</guid>
      <dc:creator>cdubs</dc:creator>
      <dc:date>2018-01-26T23:50:20Z</dc:date>
    </item>
  </channel>
</rss>

