<?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: Overlap in periods in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Overlap-in-periods/m-p/547899#M151877</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN class="login-bold"&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205" target="_self"&gt;novinosrin&lt;/A&gt;, I appreciate the response and apologize for not being clear. I wanted to retain all intervals from start2-end2 that overlap with the intervals from start1-end1 even if the overlap was one day.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Apr 2019 13:26:42 GMT</pubDate>
    <dc:creator>lillymaginta</dc:creator>
    <dc:date>2019-04-02T13:26:42Z</dc:date>
    <item>
      <title>Overlap in periods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Overlap-in-periods/m-p/547621#M151771</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
  input patientid  start1_date : mmddyy10. end1_date : mmddyy10. start2 : mmddyy10.  end2 : mmddyy10. ;
  format  start1_date end1_date start2 end2  mmddyy10.;
datalines;
1 5/5/2009 6/6/2009  1/1/2006 2/2/2006
1 5/5/2009 6/6/2009  2/2/2007 3/2/2007
1 5/5/2009 6/6/2009 5/1/2009 6/1/2009
1 5/5/2009 6/6/2009 7/7/2009 12/1/2009;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have the above data. I am trying to create a subset that includes all periods for (start2-end2) that overlap with any of the intervals from (start1_date- end1_date). No requirement for a minimum overlap in days.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Required output for this data&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;1 5/5/2009 6/6/2009 5/1/2009 6/1/2009&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 14:07:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Overlap-in-periods/m-p/547621#M151771</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2019-04-01T14:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: Overlap in periods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Overlap-in-periods/m-p/547634#M151775</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/72105"&gt;@lillymaginta&lt;/a&gt;&amp;nbsp; While I always enjoyed attempting to solve your questions, this one is not quite clear. I m wary of my understanding of the requirement.&lt;/P&gt;
&lt;P&gt;Anyways:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
  input patientid  start1_date : mmddyy10. end1_date : mmddyy10. start2 : mmddyy10.  end2 : mmddyy10. ;
  format  start1_date end1_date start2 end2  mmddyy10.;
datalines;
1 5/5/2009 6/6/2009  1/1/2006 2/2/2006
1 5/5/2009 6/6/2009  2/2/2007 3/2/2007
1 5/5/2009 6/6/2009 5/1/2009 6/1/2009
1 5/5/2009 6/6/2009 7/7/2009 12/1/2009
;
run;

proc sql;
create table want(drop=x:) as
select *,abs (start2-start1_date) as x1,abs(end2-end1_date) as x2
from a
group by patientid
having min(abs (start2-start1_date))=x1 and min(abs(end2-end1_date))=x2
order by patientid,start2,end2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Apr 2019 15:25:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Overlap-in-periods/m-p/547634#M151775</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-01T15:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: Overlap in periods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Overlap-in-periods/m-p/547642#M151777</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I propose this solution:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
  input patientid  start1_date : mmddyy10. end1_date : mmddyy10. start2 : mmddyy10.  end2 : mmddyy10. ;
  format  start1_date end1_date start2 end2  mmddyy10.;
datalines;
1 5/5/2009 6/6/2009  1/1/2006 2/2/2006
1 5/5/2009 6/6/2009  2/2/2007 3/2/2007
1 5/5/2009 6/6/2009 5/1/2009 6/1/2009
1 5/5/2009 6/6/2009 7/7/2009 12/1/2009
;
run;

data b;
do until (last.patientid);
set a;
by patientid;
if intnx('month',start1_date,0,"BEGINNING")=intnx('month',start2,0,"BEGINNING")
and 
intnx('month',end1_date,0,"BEGINNING")=intnx('month',end2,0,"BEGINNING")
then output;
end;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Apr 2019 15:39:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Overlap-in-periods/m-p/547642#M151777</guid>
      <dc:creator>mansour_ib_sas</dc:creator>
      <dc:date>2019-04-01T15:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Overlap in periods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Overlap-in-periods/m-p/547899#M151877</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN class="login-bold"&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205" target="_self"&gt;novinosrin&lt;/A&gt;, I appreciate the response and apologize for not being clear. I wanted to retain all intervals from start2-end2 that overlap with the intervals from start1-end1 even if the overlap was one day.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 13:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Overlap-in-periods/m-p/547899#M151877</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2019-04-02T13:26:42Z</dc:date>
    </item>
  </channel>
</rss>

