<?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: Flagging Overlapping Dates that contribute to &amp;gt;=15 Days in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576433#M163163</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122002"&gt;@VDD&lt;/a&gt;&amp;nbsp; &amp;nbsp;I think yes for the reason &lt;EM&gt;"irrespective of medication"&lt;/EM&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jul 2019 01:59:44 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-07-25T01:59:44Z</dc:date>
    <item>
      <title>Flagging Overlapping Dates that contribute to &gt;=15 Days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576417#M163156</link>
      <description>&lt;P&gt;I have a data set of patients who have been taking medication for certain amounts of time. I am trying to flag the days 'Y' where they take any drug for &amp;gt;=15 consecutive days but also flag the days as 'N' that don't contribute to those &amp;gt;=15 consecutive days irrespective of medication&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input ID $ medication start_date :date. end_date :date.;
    datalines;
A005 1 01SEP2016 01SEP2016
A005 2 02SEP2016 02SEP2016
A005 1 16SEP2016 19SEP2016
A005 3 19SEP2016 30SEP2016 &lt;BR /&gt;A006 1 01OCT2016 03OCT2016
A006 1 05OCT2016 15OCT2016
A006 1 11OCT2016 19OCT2016
A006 3 31OCT2016 31OCT2016
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Because the dates are on various lines, I dont know how to flag them when they overlap. Is there anyway I can do this? Perhaps I have to create an intermediate variable?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    input ID $ medication	start_date :date. enddate :date. flag;
    datalines;
A005 1 01SEP2016 01SEP2016 N
A005 2 02SEP2016 02SEP2016 N
A005 1 16SEP2016 19SEP2016 Y
A005 3 19SEP2016 30SEP2016 Y
A006 1 01OCT2016 03OCT2016 N 
A006 1 05OCT2016 15OCT2016 Y
A006 1 11OCT2016 19OCT2016 Y
A006 3 31OCT2016 31OCT2016 N
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2019 14:30:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576417#M163156</guid>
      <dc:creator>serena13lee</dc:creator>
      <dc:date>2019-07-25T14:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging Overlapping Dates that contribute to &gt;=15 Days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576424#M163159</link>
      <description>How big are you data sets and how many medications are you dealing with here? One common approach that drastically simplifies these analysis is to create a record for each date and then indicate which drugs are present on each date. But that can make your data set very long very quickly so for larger datasets a  more succint approach is desired.</description>
      <pubDate>Thu, 25 Jul 2019 01:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576424#M163159</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-25T01:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging Overlapping Dates that contribute to &gt;=15 Days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576425#M163160</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/250829"&gt;@serena13lee&lt;/a&gt;&amp;nbsp; Keeping it simple&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input ID $ medication start_date :date9. end_date :date9.;
	format 	start_date end_date date9.;
    datalines;
A005 1 01SEP2016 01SEP2016
A005 2 02SEP2016 02SEP2016
A005 1 16SEP2016 19SEP2016
A005 3 19SEP2016 30SEP2016
A006 1 01OCT2016 03OCT2016
A006 1 05OCT2016 15OCT2016
A006 1 11OCT2016 19OCT2016
A006 3 31OCT2016 31OCT2016
;


data temp;
set have;
by id;
if first.id then  f=1;
else if start_date&amp;gt;lag(end_date) then	f+1;
run;


proc sql;
create table want(drop=f) as
select *, ifc(max(end_date)-min(start_date)+1&amp;gt;=15,'Y','N') as Flag
from temp
group by id,f
order by id, start_date;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2019 01:42:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576425#M163160</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-25T01:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging Overlapping Dates that contribute to &gt;=15 Days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576427#M163161</link>
      <description>&lt;P&gt;Are you sure that you want this record marked as Y&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffc0; color: maroon; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.2; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;A005 3 19SEP2016 30SEP2016 Y&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 01:34:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576427#M163161</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-07-25T01:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging Overlapping Dates that contribute to &gt;=15 Days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576433#M163163</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122002"&gt;@VDD&lt;/a&gt;&amp;nbsp; &amp;nbsp;I think yes for the reason &lt;EM&gt;"irrespective of medication"&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 01:59:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576433#M163163</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-25T01:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging Overlapping Dates that contribute to &gt;=15 Days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576610#M163237</link>
      <description>&lt;P&gt;Hi and thank you so much for your solution. I fitted your code to my data but realized that I didn't capture patients like the following. Patients who ended medication 01SEP2016 then restarted 02SEP2016 should also be part of the consecutive count. Is there anyway I can capture this? Perhaps another lag?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    input ID $ medication start_date :date9. end_date :date9. flag;
	format 	start_date end_date date9.;
    datalines;
A007 1 01SEP2016 01SEP2016 Y
A007 2 02SEP2016 03SEP2016 Y
A007 1 03SEP2016 19SEP2016 Y
A007 3 19SEP2016 30SEP2016 Y
; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2019 14:27:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576610#M163237</guid>
      <dc:creator>serena13lee</dc:creator>
      <dc:date>2019-07-25T14:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging Overlapping Dates that contribute to &gt;=15 Days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576611#M163238</link>
      <description>Hi! Yes since it contributes to the patient being on any medication &amp;gt;=15 consecutive days. Thanks for clarifying!</description>
      <pubDate>Thu, 25 Jul 2019 14:28:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576611#M163238</guid>
      <dc:creator>serena13lee</dc:creator>
      <dc:date>2019-07-25T14:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging Overlapping Dates that contribute to &gt;=15 Days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576632#M163244</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/250829"&gt;@serena13lee&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this and let me know&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input ID $ medication start_date :date9. end_date :date9.;
	format 	start_date end_date date9.;
    datalines;
A005 1 01SEP2016 01SEP2016
A005 2 02SEP2016 02SEP2016
A005 1 16SEP2016 19SEP2016
A005 3 19SEP2016 30SEP2016
A006 1 01OCT2016 03OCT2016
A006 1 05OCT2016 15OCT2016
A006 1 11OCT2016 19OCT2016
A006 3 31OCT2016 31OCT2016
A007 1 01SEP2016 01SEP2016
A007 2 02SEP2016 03SEP2016
A007 1 03SEP2016 19SEP2016
A007 3 19SEP2016 30SEP2016
;



data temp;
set have;
by id ;
retain e;
if first.id then  f=1;
else if start_date-e&amp;gt;1 then f+1;
e=end_date;
drop e;
run;



proc sql;
create table want(drop=f) as
select *, ifc(max(end_date)-min(start_date)+1&amp;gt;=15,'Y','N') as Flag
from temp
group by id,f
order by id, start_date;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2019 15:00:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576632#M163244</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-25T15:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging Overlapping Dates that contribute to &gt;=15 Days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576939#M163389</link>
      <description>&lt;P&gt;Thanks again with your quick reply. Your second solution was able to identify those consecutive dates. Both solutions were very clean and robust. Thank you for sharing them with me. I was able to run to successfully get the desired dataset.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2019 15:29:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/576939#M163389</guid>
      <dc:creator>serena13lee</dc:creator>
      <dc:date>2019-07-26T15:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging Overlapping Dates that contribute to &gt;=15 Days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/578610#M164124</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apologies for the follow up question. I just realized that with this code, it returns a note: "&lt;SPAN&gt;The query requires remerging summary statistics back with the original data." I was wondering if there was a way to remove this? After reading this paper&amp;nbsp;&lt;A href="https://support.sas.com/resources/papers/proceedings/proceedings/sugi28/103-28.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings/proceedings/sugi28/103-28.pdf&lt;/A&gt;&amp;nbsp;it appears to be either due to the select * or the max().&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 04:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/578610#M164124</guid>
      <dc:creator>serena13lee</dc:creator>
      <dc:date>2019-08-02T04:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging Overlapping Dates that contribute to &gt;=15 Days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/578646#M164147</link>
      <description>&lt;P&gt;The remerge was done it chosen on purpose. That's basically is the logic to get the "want". I'm just waking up. I'll message you once I get to work with a fix&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 09:41:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/578646#M164147</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-02T09:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging Overlapping Dates that contribute to &gt;=15 Days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/578687#M164171</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/250829"&gt;@serena13lee&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data temp;
set have;
by id ;
retain e;
if first.id then  f=1;
else if start_date-e&amp;gt;1 then f+1;
e=end_date;
drop e;
run;

proc sql;
create table want(drop=f) as
select a.*,Flag
from
temp a inner join (select id,f, ifc(max(end_date)-min(start_date)+1&amp;gt;=15,'Y','N') as Flag from temp group by id,f) b
on a.id=b.id and a.f=b.f
order by id, start_date;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Aug 2019 13:10:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-Overlapping-Dates-that-contribute-to-gt-15-Days/m-p/578687#M164171</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-08-02T13:10:04Z</dc:date>
    </item>
  </channel>
</rss>

