<?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: To find continuity in enrollment of a patient in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296871#M62270</link>
    <description>&lt;PRE&gt;
I am not following the message after that.
My code would not take care of duplicated value,since it is monthly (1-12) data.

if you want that change:
i =-11 to 0 
--&amp;gt;
i=-12 to -1


My code will give you the exact number as the number of original dataset.


If you have some data like this, mine is different with PG.
id   date
1   01jan2010
1   10feb2010
1   01jan2010
1   01jan2010

&lt;/PRE&gt;</description>
    <pubDate>Wed, 07 Sep 2016 00:54:02 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-09-07T00:54:02Z</dc:date>
    <item>
      <title>To find continuity in enrollment of a patient</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296204#M61995</link>
      <description>&lt;P&gt;To find zero interval continuity..&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2016 12:08:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296204#M61995</guid>
      <dc:creator>Reema</dc:creator>
      <dc:date>2016-09-12T12:08:03Z</dc:date>
    </item>
    <item>
      <title>Re: To find continuity in enrollment of a patient</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296233#M62001</link>
      <description>&lt;P&gt;I interpreted your date interval requirement as continuous enrolment for the twelve months prior the index month, for the index month and for the eleven months after the index month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data enrolment;
set sasforum.annual_cut;
array memday{12};
indexMonth = intnx("MONTH", index_dt, 0);
do i = 1 to 12;
    month = mdy(i, 1, year);
    days = memday{i};
    if -12 &amp;lt;= intck("MONTH", indexMonth, month) &amp;lt;= 11 then output;
    end;
format month indexMonth yymm.;
keep enrolId indexMonth month days;
run;

proc sql;
create table continuous as
select enrolId, indexMonth
from enrolment
group by enrolId, indexMonth
having sum(days) &amp;gt;= 2*365;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Sep 2016 20:16:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296233#M62001</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-09-02T20:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: To find continuity in enrollment of a patient</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296293#M62023</link>
      <description>&lt;PRE&gt;
OK. Test it on your own. I have no time to check it.



data key;
 set annual_cut;
 array x{*} memday1-memday12;
 do i=1 to dim(x);
  monyy=put(mdy(i,1,year),monyy7.);
  value=x{i};
  output;
 end;
 keep enrolid monyy value;
run;

data want;
 if _n_=1 then do;
  if 0 then set key;
  declare hash h(dataset:'key',hashexp:20);
  h.definekey('enrolid','monyy');
  h.definedata('value');
  h.definedone();
 end;
set annual_cut;
pre_sum=0;
 do i=-11 to 0;
  monyy=put(intnx('month',index_dt,i),monyy7.);
  if h.find()=0 then pre_sum+value;
 end;

post_sum=0;
 do j=0 to 11;
  monyy=put(intnx('month',index_dt,j),monyy7.);
  if h.find()=0 then post_sum+value;
 end;
 
if pre_sum ge 365 and post_sum ge 365 then output;

drop i j monyy value;
run;

&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Sep 2016 06:30:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296293#M62023</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-03T06:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: To find continuity in enrollment of a patient</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296296#M62026</link>
      <description>&lt;P&gt;To find zero interval continuity.. 02&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2016 12:12:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296296#M62026</guid>
      <dc:creator>Reema</dc:creator>
      <dc:date>2016-09-12T12:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: To find continuity in enrollment of a patient</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296297#M62027</link>
      <description>&lt;P&gt;Thank you Ksharp, for your time and efforts..&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2016 10:14:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296297#M62027</guid>
      <dc:creator>Reema</dc:creator>
      <dc:date>2016-09-03T10:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: To find continuity in enrollment of a patient</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296298#M62028</link>
      <description>&lt;P&gt;Thanks PGStats..&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2016 10:23:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296298#M62028</guid>
      <dc:creator>Camp</dc:creator>
      <dc:date>2016-09-03T10:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: To find continuity in enrollment of a patient</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296299#M62029</link>
      <description>&lt;P&gt;Thanks Ksharp..&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2016 10:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296299#M62029</guid>
      <dc:creator>Camp</dc:creator>
      <dc:date>2016-09-03T10:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: To find continuity in enrollment of a patient</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296349#M62058</link>
      <description>&lt;P&gt;It is simpler to change the approach slightly because there can be anywhere between 365+365+28 and 365+366+31 days in 25 consecutive months. The new approach is: 1) keep only complete months within the desired range, then 2) select ranges that include exactly 25 consecutive months.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data enrolment;
set sasforum.annual_cut;
array memday{12};
indexMonth = intnx("MONTH", index_dt, 0);
do i = 1 to 12;
    month = mdy(i, 1, year);
    days = memday{i};
    if -12 &amp;lt;= intck("MONTH", indexMonth, month) &amp;lt;= 12 and
        days = intck("DAY", month, intnx("MONTH", month, 1))then output;
    end;
format month indexMonth yymm.;
keep enrolId indexMonth month;
run;

proc sql;
create table continuous as
select enrolId, indexMonth
from enrolment
group by enrolId, indexMonth
having count(month) = 25;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Sep 2016 03:19:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296349#M62058</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-09-04T03:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: To find continuity in enrollment of a patient</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296351#M62060</link>
      <description>&lt;PRE&gt;
PG,
Why not use RANGE() in your original code?



proc sql;
create table continuous as 
select enrolId, indexMonth,  range(indexMonth) as range
from enrolment
group by enrolId, indexMonth
having sum(days) &amp;gt;= 2*365;
quit;

&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Sep 2016 03:41:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296351#M62060</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-04T03:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: To find continuity in enrollment of a patient</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296354#M62063</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp﻿&lt;/a&gt;,&amp;nbsp;I guess you mean RANGE(month)? I can't see how that would help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See new version of the code for a simpler solution that can also accomodate any number of consecutive months.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Sep 2016 03:53:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296354#M62063</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-09-04T03:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: To find continuity in enrollment of a patient</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296513#M62146</link>
      <description>&lt;P&gt;Hi Ksharp,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The codes that you have provided to me (which are aliter for below codes provided by PGStats) are giving distinct number of observations. Can you please look into it.&lt;/P&gt;&lt;P&gt;1. Even after changing the pre_sum do interval to: &amp;lt;do i =-12 to -1&amp;gt; and,&lt;/P&gt;&lt;P&gt;2. I am sure that there are no duplicates in final dataset that I get after running PGStats codes and your codes.&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 procnames"&gt;data&lt;/SPAN&gt; enrolment&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; sasforum&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;annual_cut&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token statement"&gt;array&lt;/SPAN&gt; memday&lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;12&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
indexMonth &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;intnx&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; index_dt&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
do i &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; to &lt;SPAN class="token number"&gt;12&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="token function"&gt;month&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;mdy&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&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 function"&gt;year&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    days &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; memday&lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;-12&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;lt;=&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; indexMonth&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;month&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;11&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; output&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;format&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;month&lt;/SPAN&gt; indexMonth yymm&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;keep&lt;/SPAN&gt; enrolId indexMonth &lt;SPAN class="token function"&gt;month&lt;/SPAN&gt; days&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;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;sql&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
create &lt;SPAN class="token statement"&gt;table&lt;/SPAN&gt; continuous as
&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; enrolId&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; indexMonth
&lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; enrolment
&lt;SPAN class="token keyword"&gt;group&lt;/SPAN&gt; &lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; enrolId&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; indexMonth
having &lt;SPAN class="token function"&gt;sum&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;days&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;2&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;365&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;quit&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;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2016 11:53:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296513#M62146</guid>
      <dc:creator>Reema</dc:creator>
      <dc:date>2016-09-05T11:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: To find continuity in enrollment of a patient</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296635#M62198</link>
      <description>&lt;PRE&gt;
That is because I counted
month=-11 to 0 
AND
month=0 to 11

Notice: I count month=0 twice.


PG only count month=0 once .


&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Sep 2016 05:33:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296635#M62198</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-06T05:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: To find continuity in enrollment of a patient</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296675#M62212</link>
      <description>&lt;P&gt;Sorry Ksharp, but in last message I replied that I have changed the first &lt;STRONG&gt;do&amp;nbsp;loop&lt;/STRONG&gt;&amp;nbsp;for&amp;nbsp;pre_sum to &lt;STRONG&gt;-12 to -1&lt;/STRONG&gt; and I have checked that there are no duplicates in final datasets of yours i.e. "want" and final dataset of PG i.e. "continuous" and as I last remember yours' codes were giving less number of observations as compared to PG's.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2016 18:03:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296675#M62212</guid>
      <dc:creator>Reema</dc:creator>
      <dc:date>2016-09-06T18:03:35Z</dc:date>
    </item>
    <item>
      <title>Re: To find continuity in enrollment of a patient</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296871#M62270</link>
      <description>&lt;PRE&gt;
I am not following the message after that.
My code would not take care of duplicated value,since it is monthly (1-12) data.

if you want that change:
i =-11 to 0 
--&amp;gt;
i=-12 to -1


My code will give you the exact number as the number of original dataset.


If you have some data like this, mine is different with PG.
id   date
1   01jan2010
1   10feb2010
1   01jan2010
1   01jan2010

&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Sep 2016 00:54:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-continuity-in-enrollment-of-a-patient/m-p/296871#M62270</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-07T00:54:02Z</dc:date>
    </item>
  </channel>
</rss>

