<?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 Keep records with 60 or more days of gap in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Keep-records-with-60-or-more-days-of-gap/m-p/544539#M150605</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input id$2. start  end ;
attrib start format =date9. informat=date9.;
attrib end format =date9. informat=date9.;
datalines;
1 01JAN2015 14FEB2015
1 18FEB2015 30APR2015

2 01jan2015 28JAN2015
2 01apr2015 30apr2015&lt;BR /&gt;
3 01JAN2015 14FEB2015
3 15FEB2015 15MAR2015
3 20MAR2015 30APR2015
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have the above data, there are multiple records per id I want to apply the following criteria:&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;-keep all records with more than 60 days gap between end of one period and the start of the other&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;-keep only the first record if if the end dat of one period and the start of ther others are less than 60 days&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;2 01apr2015 30apr2015&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;1 01JAN2015 14FEB2015&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;2 01jan2015 28JAN2015 &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;2 01apr2015 30apr2015&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;3 01JAN2015 14FEB2015&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Mar 2019 13:12:31 GMT</pubDate>
    <dc:creator>lillymaginta</dc:creator>
    <dc:date>2019-03-20T13:12:31Z</dc:date>
    <item>
      <title>Keep records with 60 or more days of gap</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-records-with-60-or-more-days-of-gap/m-p/544539#M150605</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input id$2. start  end ;
attrib start format =date9. informat=date9.;
attrib end format =date9. informat=date9.;
datalines;
1 01JAN2015 14FEB2015
1 18FEB2015 30APR2015

2 01jan2015 28JAN2015
2 01apr2015 30apr2015&lt;BR /&gt;
3 01JAN2015 14FEB2015
3 15FEB2015 15MAR2015
3 20MAR2015 30APR2015
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have the above data, there are multiple records per id I want to apply the following criteria:&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;-keep all records with more than 60 days gap between end of one period and the start of the other&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;-keep only the first record if if the end dat of one period and the start of ther others are less than 60 days&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;2 01apr2015 30apr2015&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;1 01JAN2015 14FEB2015&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;2 01jan2015 28JAN2015 &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;2 01apr2015 30apr2015&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;3 01JAN2015 14FEB2015&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2019 13:12:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-records-with-60-or-more-days-of-gap/m-p/544539#M150605</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2019-03-20T13:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: Keep records with 60 or more days of gap</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-records-with-60-or-more-days-of-gap/m-p/544548#M150607</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input id$2. start  end ;
attrib start format =date9. informat=date9.;
attrib end format =date9. informat=date9.;
datalines;
1 01JAN2015 14FEB2015
1 18FEB2015 30APR2015
2 01jan2015 28JAN2015
2 01apr2015 30apr2015
3 01JAN2015 14FEB2015
3 15FEB2015 15MAR2015
3 20MAR2015 30APR2015
;
run;

data want;
set test;
by id;
l=lag(end);
if first.id then f=1;
else do;
if  start-l&amp;gt;60 then f=1;
else f=0;
end;
if f;
drop l f;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Mar 2019 13:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-records-with-60-or-more-days-of-gap/m-p/544548#M150607</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-20T13:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: Keep records with 60 or more days of gap</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-records-with-60-or-more-days-of-gap/m-p/544549#M150608</link>
      <description>&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2019 13:15:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-records-with-60-or-more-days-of-gap/m-p/544549#M150608</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2019-03-20T13:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: Keep records with 60 or more days of gap</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-records-with-60-or-more-days-of-gap/m-p/544550#M150609</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; You are welcome. Plus, Thank you for posting the sample HAVE and WANT clearly. That makes it so much convenient.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2019 13:17:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-records-with-60-or-more-days-of-gap/m-p/544550#M150609</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-20T13:17:00Z</dc:date>
    </item>
  </channel>
</rss>

