<?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: creating a time window for event occurences in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/creating-a-time-window-for-event-occurences/m-p/914897#M360538</link>
    <description>&lt;P&gt;Can you explain the logic for choosing the rows to output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Feb 2024 18:03:50 GMT</pubDate>
    <dc:creator>SASJedi</dc:creator>
    <dc:date>2024-02-07T18:03:50Z</dc:date>
    <item>
      <title>creating a time window for event occurences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-time-window-for-event-occurences/m-p/914878#M360529</link>
      <description>&lt;P&gt;Trying to get this manipulation going and any thoughts/help on this is appreciated.&lt;/P&gt;&lt;P&gt;Dataset Sample&lt;/P&gt;&lt;P&gt;id&amp;nbsp; &amp;nbsp; status&amp;nbsp; &amp;nbsp;date&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;OK&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02-MAY-09&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; OK&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10-MAY-09&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; DEL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01-JUL-22&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; OK&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01-DEC-22&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; OK&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 04-DEC-22&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; DEL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 06-DEC-22&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp;DEL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01-JAN-23&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp;OK&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03-JAN-23&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp;DEL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 04-JAN-23&lt;/P&gt;&lt;P&gt;4&amp;nbsp; DEL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05-JAN-23&lt;/P&gt;&lt;P&gt;4&amp;nbsp; OK&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;06-JAN23&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking for the following output which can be long or wide format&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;OK&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02-MAY-09&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; DEL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01-JUL-22&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; OK&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01-DEC-22&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; DEL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 06-DEC-22&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp;DEL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01-JAN-23&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp;OK&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03-JAN-23&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp;DEL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 04-JAN-23&lt;/P&gt;&lt;P&gt;4&amp;nbsp; OK&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 06-JAN23&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2024 16:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-time-window-for-event-occurences/m-p/914878#M360529</guid>
      <dc:creator>jins</dc:creator>
      <dc:date>2024-02-07T16:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: creating a time window for event occurences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-time-window-for-event-occurences/m-p/914897#M360538</link>
      <description>&lt;P&gt;Can you explain the logic for choosing the rows to output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2024 18:03:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-time-window-for-event-occurences/m-p/914897#M360538</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2024-02-07T18:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: creating a time window for event occurences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-time-window-for-event-occurences/m-p/914904#M360542</link>
      <description>&lt;P&gt;I should have mentioned that oops....&lt;/P&gt;&lt;P&gt;To obtain the date of the first occurrence between the status change by ID. For example ID-1 has two OK status before the DEL status, so we keep the first one with date 02-May-2009. For ID's with no status changes, it is output as is (ID-2).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2024 18:30:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-time-window-for-event-occurences/m-p/914904#M360542</guid>
      <dc:creator>jins</dc:creator>
      <dc:date>2024-02-07T18:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: creating a time window for event occurences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-time-window-for-event-occurences/m-p/914909#M360547</link>
      <description>&lt;P&gt;Is the notsorted option in the by variable a good idea to filter them out if the data is already sorted prior by id, date and status?&lt;/P&gt;&lt;P&gt;data check;&lt;/P&gt;&lt;P&gt;by id status notsorted;&lt;/P&gt;&lt;P&gt;if first.status=1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2024 19:00:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-time-window-for-event-occurences/m-p/914909#M360547</guid>
      <dc:creator>jins</dc:creator>
      <dc:date>2024-02-07T19:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: creating a time window for event occurences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-time-window-for-event-occurences/m-p/914973#M360558</link>
      <description>&lt;P&gt;Same selection logic as already suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/84674"&gt;@jins&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input id status $ dt:date11.;
  format dt date9.;
  datalines;
1 OK 02-MAY-09
1 OK 10-MAY-09
1 DEL 01-JUL-22
1 OK 01-DEC-22
1 OK 04-DEC-22
1 DEL 06-DEC-22
2 DEL 01-JAN-23
3 OK 03-JAN-23
4 DEL 04-JAN-23
4 DEL 05-JAN-23
4 OK 06-JAN23
;

/* ensure source data is sorted as required */
proc sort data=have presorted;
  by id dt;
run;

data want;
  set have;
  by id status notsorted;
  if first.status;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2024 01:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-time-window-for-event-occurences/m-p/914973#M360558</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-02-08T01:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: creating a time window for event occurences</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-time-window-for-event-occurences/m-p/914985#M360564</link>
      <description>&lt;P&gt;thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2024 00:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-time-window-for-event-occurences/m-p/914985#M360564</guid>
      <dc:creator>jins</dc:creator>
      <dc:date>2024-02-08T00:36:09Z</dc:date>
    </item>
  </channel>
</rss>

