<?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 to get records with time gap of certain number of days in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-records-with-time-gap-of-certain-number-of-days/m-p/937556#M368391</link>
    <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT;
  set HAVE;
  by PERSON_ID;
  DIF = dif(OCCURANCE_DATE);
  if DIF&amp;gt;=35 or first.PERSON_ID ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jul 2024 05:02:04 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2024-07-30T05:02:04Z</dc:date>
    <item>
      <title>How to get records with time gap of certain number of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-records-with-time-gap-of-certain-number-of-days/m-p/937554#M368389</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I have a list of records with dates related to each person and want to only keep the records that give at least time gap of 31 days. The HAVE data set is what I have, and WANT is the target data file. Can anyone guide how to go from HAVE to WANT? Thank you in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input person_id occurance_date :mmddyy.;&lt;BR /&gt;format occurance_date mmddyy.;&lt;BR /&gt;cards;&lt;BR /&gt;1 1/5/2023&lt;BR /&gt;2 8/21/2023&lt;BR /&gt;2 9/25/2023&lt;BR /&gt;3 1/5/2023&lt;BR /&gt;3 2/1/2023&lt;BR /&gt;4 1/22/2023&lt;BR /&gt;4 1/29/2023&lt;BR /&gt;4 3/9/2023&lt;BR /&gt;4 3/10/2023&lt;BR /&gt;4 3/14/2023&lt;BR /&gt;4 5/1/2023&lt;BR /&gt;4 6/11/2023&lt;BR /&gt;4 6/15/2023&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;data want;&lt;BR /&gt;input person_id eff_occurance_date :mmddyy.;&lt;BR /&gt;format eff_occurance_date mmddyy.;&lt;BR /&gt;cards;&lt;BR /&gt;1 1/5/2023&lt;BR /&gt;2 8/21/2023&lt;BR /&gt;2 9/25/2023&lt;BR /&gt;3 1/5/2023&lt;BR /&gt;4 1/22/2023&lt;BR /&gt;4 3/9/2023&lt;BR /&gt;4 5/1/2023&lt;BR /&gt;4 6/11/2023&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2024 04:22:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-records-with-time-gap-of-certain-number-of-days/m-p/937554#M368389</guid>
      <dc:creator>lichee</dc:creator>
      <dc:date>2024-07-30T04:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to get records with time gap of certain number of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-records-with-time-gap-of-certain-number-of-days/m-p/937556#M368391</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT;
  set HAVE;
  by PERSON_ID;
  DIF = dif(OCCURANCE_DATE);
  if DIF&amp;gt;=35 or first.PERSON_ID ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2024 05:02:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-records-with-time-gap-of-certain-number-of-days/m-p/937556#M368391</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-07-30T05:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to get records with time gap of certain number of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-records-with-time-gap-of-certain-number-of-days/m-p/937615#M368414</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/430334"&gt;@lichee&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I have a list of records with dates related to each person and want to only keep the records that give at least time gap of 31 days. The HAVE data set is what I have, and WANT is the target data file. Can anyone guide how to go from HAVE to WANT? Thank you in advance!&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think you missing a detail or two.&lt;/P&gt;
&lt;P&gt;Since there is only one record at all with Person_id=1 there is no gap at all. So how does it have a gap of "at least 31 days"?&lt;/P&gt;
&lt;P&gt;You say "records that give at least time of 31 days" but the Want shows a single record for Person_id=3. What "gap" was used for that determination as the only other Person_id=3 is less than 31 days later. So why is that record chosen to keep.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2024 14:06:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-records-with-time-gap-of-certain-number-of-days/m-p/937615#M368414</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-07-30T14:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to get records with time gap of certain number of days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-records-with-time-gap-of-certain-number-of-days/m-p/937643#M368425</link>
      <description>&lt;P&gt;If you have 3 records dates 20MAR, 01APR, and 28APR, do you keep the third record (it is more than 31 days after the last kept record (20MAR), but only 27 days after the last record encountered (01APR).&amp;nbsp; If the answer is yes, and if your data are sorted by ID/DATE, then:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input person_id occurance_date :mmddyy.;
format occurance_date mmddyy.;
cards;
1 1/5/2023
2 8/21/2023
2 9/25/2023
3 1/5/2023
3 2/1/2023
4 1/22/2023
4 1/29/2023
4 3/9/2023
4 3/10/2023
4 3/14/2023
4 5/1/2023
4 6/11/2023
4 6/15/2023
run;

data want (drop=_:);
  set have;
  by person_id;
  retain _allowable_date ;
  if first.person_id=1 or occurance_date&amp;gt;_allowable_date;
  _allowable_date=occurance_date+32;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2024 16:44:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-records-with-time-gap-of-certain-number-of-days/m-p/937643#M368425</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-07-30T16:44:31Z</dc:date>
    </item>
  </channel>
</rss>

