<?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: How do I remove redundant datelines within a predefined period? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429640#M106138</link>
    <description>&lt;P&gt;Ok - that makes sense:-) Thanks again!&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jan 2018 15:01:59 GMT</pubDate>
    <dc:creator>TineKopp</dc:creator>
    <dc:date>2018-01-22T15:01:59Z</dc:date>
    <item>
      <title>How do I remove redundant datelines within a predefined period?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429611#M106125</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I have retrieved data on abortions (date of abortions=d_inddto))&amp;nbsp;from a hospital discharge registry. Sometimes there are several abortions (dates)&amp;nbsp;per person within a short period of time (for example 4 dates in 10 days), which I know is not right. On the other hand, one person can have multiple abortions - but there should be at least 12 weeks between each abortion. &amp;nbsp;So, I want to make a rule that says that in a period of 12 weeks or 84 days, only 1 abortion (that is, only on date) should remain in my dataset per person (PNR). And it should only be the first date. How do I do that? My data looks like this:&lt;/P&gt;&lt;P&gt;PNR&amp;nbsp; d_inddto&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 13/11/2013&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;14/11/2013&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20/11/2013&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22/11/2013&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 24/05/2015&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01/09/2006&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 13:56:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429611#M106125</guid>
      <dc:creator>TineKopp</dc:creator>
      <dc:date>2018-01-22T13:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove redundant datelines within a predefined period?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429613#M106127</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by PNR;
retain last_date;
if first.PNR
then last_date = d_inddto;
else if intck('week',last_date,d_inddto) le 12
then delete;
else last_date = d_inddto;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Untested. For tested code, supply example data in a data step.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 14:04:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429613#M106127</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-22T14:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove redundant datelines within a predefined period?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429614#M106128</link>
      <description>&lt;P&gt;How about something like this?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set have;
	by pnr;
	_prevdate = lag(d_inddto);
	if first.pnr or (d_inddto - _prevdate) &amp;gt;= 84;
	drop _prevdate;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is just based on 84 days, without regard to week boundaries.&amp;nbsp; It assumes the input dataset is already sorted by ascending values of pnr and d_inddto.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Josh&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: syntax correction to code above&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 14:52:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429614#M106128</guid>
      <dc:creator>jmhorstman</dc:creator>
      <dc:date>2018-01-22T14:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove redundant datelines within a predefined period?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429616#M106129</link>
      <description>&lt;P&gt;Thank you very much. It seems to work perfectly:-)&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 14:24:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429616#M106129</guid>
      <dc:creator>TineKopp</dc:creator>
      <dc:date>2018-01-22T14:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove redundant datelines within a predefined period?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429621#M106130</link>
      <description>&lt;P&gt;Thank you for your answer! Unfortunately, it removes all datelines except for the first one. Or maybe I haven't used it correctly..... Nevertheless, I got an answer by KurtBremser that seems to work better on my data. Again, thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 14:29:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429621#M106130</guid>
      <dc:creator>TineKopp</dc:creator>
      <dc:date>2018-01-22T14:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove redundant datelines within a predefined period?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429629#M106132</link>
      <description>&lt;P&gt;My mistake - I made a slight in error in the code.&amp;nbsp; I've corrected it above.&amp;nbsp; My apologies - I was in too much of a hurry to be the first responder and earn precious badges.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Josh&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 14:53:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429629#M106132</guid>
      <dc:creator>jmhorstman</dc:creator>
      <dc:date>2018-01-22T14:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove redundant datelines within a predefined period?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429631#M106133</link>
      <description>&lt;P&gt;It is correct that in the very small dataset, I would expect only 3 records. However, if the dataset looked like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PNR&amp;nbsp; d_inddto&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 13/11/2013&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;14/11/2013&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20/11/2013&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22/11/2013&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 03/05/2017&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 24/05/2015&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01/09/2006&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;there should be 4 records left. I haven't tried it myself since I'm just trying to help a colleague. She said it didn't work on her data. But as I wrote, we may have used it incorrectly.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 14:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429631#M106133</guid>
      <dc:creator>TineKopp</dc:creator>
      <dc:date>2018-01-22T14:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove redundant datelines within a predefined period?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429634#M106136</link>
      <description>Nope you used it correctly.  It was my error.  See above for the corrected version.  Thanks!</description>
      <pubDate>Mon, 22 Jan 2018 14:58:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429634#M106136</guid>
      <dc:creator>jmhorstman</dc:creator>
      <dc:date>2018-01-22T14:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove redundant datelines within a predefined period?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429640#M106138</link>
      <description>&lt;P&gt;Ok - that makes sense:-) Thanks again!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 15:01:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-remove-redundant-datelines-within-a-predefined-period/m-p/429640#M106138</guid>
      <dc:creator>TineKopp</dc:creator>
      <dc:date>2018-01-22T15:01:59Z</dc:date>
    </item>
  </channel>
</rss>

