<?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: Remove overlapping time periods in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Remove-overlapping-time-periods/m-p/837567#M36161</link>
    <description>&lt;P&gt;Is the problem always that there are two consecutive lines and one needs to be removed? Could there ever be three consecutive or non-consecutive lines where some need to be removed?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't understand the result for ID 0002, they two records overlap, why are they not combined?&lt;/P&gt;</description>
    <pubDate>Sun, 09 Oct 2022 13:42:05 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-10-09T13:42:05Z</dc:date>
    <item>
      <title>Remove overlapping time periods</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-overlapping-time-periods/m-p/837566#M36160</link>
      <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose to have the following:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;data DB1;
input ID :$20. (Start End)(:date9.) Absence_reason :$20.;
format Start End date9.;
cards;
0001 01JAN2015 06FEB2015 vacation 
0001 02JAN2015 02JAN2015 vacation 
0001 13APR2015 31DEC2015 sick leave 
0002 01JAN2017 12JUL2017 vacation 
0002 12JUN2017 18JUN2017 vacation 
...;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to remove records having the same (!) &amp;nbsp;"absence reason" when the period falls into a larger one. For example for 0001, the row 02JAN2015 - &amp;nbsp;02JAN2015 should be removed because already in 01JAN2015 - 06FEB2015. The same for 0002 relative to 12JUN2017 &amp;nbsp;- &amp;nbsp;18JUN2017. It is clearly an error in the file I received to perform the analysis.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Desired output:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;data DB1;
input ID :$20. (Start End)(:date9.) Absence_reason :$20.;
format Start End date9.;
cards;
0001 01JAN2015 06FEB2015 vacation 
0001 13APR2015 31DEC2015 sick leave 
0002 01JAN2017 12JUL2017 vacation 
...;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Oct 2022 12:53:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-overlapping-time-periods/m-p/837566#M36160</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2022-10-09T12:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Remove overlapping time periods</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-overlapping-time-periods/m-p/837567#M36161</link>
      <description>&lt;P&gt;Is the problem always that there are two consecutive lines and one needs to be removed? Could there ever be three consecutive or non-consecutive lines where some need to be removed?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't understand the result for ID 0002, they two records overlap, why are they not combined?&lt;/P&gt;</description>
      <pubDate>Sun, 09 Oct 2022 13:42:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-overlapping-time-periods/m-p/837567#M36161</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-09T13:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: Remove overlapping time periods</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-overlapping-time-periods/m-p/837568#M36162</link>
      <description>&lt;P&gt;I don't understand your questions. Data periods should not be combined, but only removed when they are sub periods of a greater one(s) by the same absence reason. The records relative to 0002 overlap and this is the reason why I would like to remove the shortest one. Unfortunately it is a mistake made by the person that annotated the absence for the worker 0002.&lt;/P&gt;</description>
      <pubDate>Sun, 09 Oct 2022 13:42:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-overlapping-time-periods/m-p/837568#M36162</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2022-10-09T13:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: Remove overlapping time periods</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-overlapping-time-periods/m-p/837569#M36163</link>
      <description>&lt;P&gt;Is it always two consecutive records where one needs to be removed? Could there ever be three records (consecutive or non-consecutive) where records need to be removed?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When there is partial overlap such as ID 0002, you want to keep the longest and remove the shortest?&lt;/P&gt;</description>
      <pubDate>Sun, 09 Oct 2022 13:43:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-overlapping-time-periods/m-p/837569#M36163</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-09T13:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: Remove overlapping time periods</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-overlapping-time-periods/m-p/837572#M36164</link>
      <description>So: "Could there ever be 3 records....?" Yes. &lt;BR /&gt;"When there is partial overlap....?" Yes, the longest is the informative one I would like to retain.</description>
      <pubDate>Sun, 09 Oct 2022 17:38:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-overlapping-time-periods/m-p/837572#M36164</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2022-10-09T17:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: Remove overlapping time periods</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-overlapping-time-periods/m-p/837642#M36173</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DB1;
input ID :$20. (Start End)(:date9.) Absence_reason $20.;
format Start End date9.;
cards;
0001 01JAN2015 06FEB2015 vacation 
0001 02JAN2015 02JAN2015 vacation 
0001 13APR2015 31DEC2015 sick leave 
0002 01JAN2017 12JUL2017 vacation 
0002 12JUN2017 18JUN2017 vacation 
;
data temp;
 set db1;
do date=start to end;
 output;
end;
drop start end;
format date date9.;
run;
proc sort data=temp out=temp2 nodupkey;
by id date Absence_reason;
run;
data temp3;
 set temp2;
if id ne lag(id) or date ne lag(date)+1 or Absence_reason ne lag(Absence_reason) then group+1;
run;
proc sql;
create table want as
select group,max(id) as id,min(date) as start format=date9.,max(date) as end format=date9.,max(Absence_reason) as Absence_reason
 from temp3
  group by group;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Oct 2022 11:39:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-overlapping-time-periods/m-p/837642#M36173</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-10-10T11:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Remove overlapping time periods</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-overlapping-time-periods/m-p/837668#M36174</link>
      <description>Thank you very much! It works perfectly!</description>
      <pubDate>Mon, 10 Oct 2022 14:36:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-overlapping-time-periods/m-p/837668#M36174</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2022-10-10T14:36:26Z</dc:date>
    </item>
  </channel>
</rss>

