<?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: RESTRICTING  RECURRENCE STATUS BASED ON TIME TIME INTERVALS BETWEEN EVENTS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502258#M134054</link>
    <description>&lt;P&gt;Thank you FreelanceReinhard for the response&amp;nbsp; about the clarification.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I have pasted your text to clarify more about the desired variable,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obviously, observations with EVENT=0 will have NEW_EVENT=0. Moreover, you've confirmed that they are to be ignored in the definition of NEW_EVENT for observations with EVENT=1 (which&amp;nbsp;we call "events"). Actually, the values s1, e1 etc. that I introduced referred to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;events&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;only.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If&amp;nbsp;&amp;nbsp;the values s1, e1 etc. that you introduced referred to&amp;nbsp;&lt;EM&gt;events&lt;/EM&gt;&amp;nbsp;only and therefore evaluating observations of (event=1) then I think the formula should evaluate (&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;if&amp;nbsp;s3-e2&amp;gt;30&lt;FONT color="#999999"&gt;)&lt;/FONT&gt;&amp;nbsp;then new_event=1; else new_event=0;&lt;/FONT&gt;&lt;SPAN&gt;"), Where&amp;nbsp; the StartDate (s3) pertains to the following (events=1) to be evaluated and the EndDate (e2)&amp;nbsp;pertains to the converted&amp;nbsp;(new_event=1).&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;In case the evaluation returns (new_event=0) the the following evaluation should disregard it and&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;STRONG&gt;evaluates the next (event=1) this time again in relation to the last known (new_event=1). This is because all (events=1) that are turned into (new_event=0) are assumed to have been also (event=0) in real settings.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;We want to assume the (event=1) observations that turn into (new_event=0) were actually (event=0) in real sense and therefore our evaluations targeting&amp;nbsp;the observations that turned into (new_event=1) and the subsequent (event=1) that remain&amp;nbsp;(new_event=1), then subsequent (event=1) that (remain new_event=1) etc. Assumption is that those (event=1) that turn into (new_event=0) were actually (event=0), then If the condition can evaluate this it will give the desired output.&lt;/STRONG&gt;&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;&lt;P&gt;We have to resolve a possible contradiction: For the third event you specify:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;"&lt;FONT face="courier new,courier"&gt;if&amp;nbsp;&lt;STRONG&gt;s3-e2&amp;gt;30&lt;FONT color="#999999"&gt;)&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;then new_event=1; else new_event=0;&lt;/FONT&gt;"&lt;/BLOCKQUOTE&gt;&lt;P&gt;Later you formulate the general rule&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The IF contrition&amp;nbsp;should evaluate from the EndDate of the previous (new_event=1)&amp;nbsp; to the&amp;nbsp; start date of next (event=1) ...&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Now consider a patient with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s2-e1&amp;lt;=30&lt;/FONT&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(hence&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;new_event=0&lt;/FONT&gt;&amp;nbsp;for the second event),&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s3-e2&amp;lt;=30&lt;/FONT&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s3-e1&amp;gt;30&lt;/FONT&gt;&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first rule implies&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;new_event=&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;for the third event, whereas the second rule (which is a bit vague) seems to suggest&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;new_event=&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The second rule may give what I expect to come out basing on your example above, because taking considering this example you have given here below&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Now consider a patient with&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s2-e1&amp;lt;=30&lt;/FONT&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;(hence&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;new_event=0&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;for the second event),&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s3-e2&amp;lt;=30&lt;/FONT&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;and&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;(&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s3-e1&amp;gt;30)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;This is what&amp;nbsp;i desire for the third event&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN style="font-weight: bold;"&gt;(&lt;/SPAN&gt;&lt;STRONG&gt;s3-e1&amp;gt;30)if the second&amp;nbsp;event(&lt;STRONG&gt;s2-e1&amp;lt;=30)&lt;/STRONG&gt;turned out to be (new_event=0&lt;/STRONG&gt;&lt;SPAN style="font-weight: bold;"&gt;)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;STRONG&gt;.&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In this case the third observation &lt;SPAN style="font-weight: bold;"&gt;(&lt;/SPAN&gt;&lt;STRONG&gt;s3-e1&amp;gt;30)&amp;nbsp;&lt;/STRONG&gt;occurs after more than 30 days from the last known (new_event=1) and therefore its a true (new_event=1) unlike the second event. &lt;STRONG&gt;This is what am desiring to get.&amp;nbsp;&lt;/STRONG&gt; And the evaluation should start again from that event afresh to evaluate the following observation in the same manner. Eg&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s2-e1&amp;lt;=30&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;(hence&amp;nbsp;&lt;FONT face="courier new,courier"&gt;new_event=0&lt;/FONT&gt;&amp;nbsp;for the second event), then next "If&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s3-e1&amp;lt;=30&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;(hence&amp;nbsp;&lt;FONT face="courier new,courier"&gt;new_event=0&lt;/FONT&gt;&amp;nbsp;for the third event), then if next evaluation "If&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s4-e1&amp;lt;=30&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;(hence&amp;nbsp;&lt;FONT face="courier new,courier"&gt;new_event=0&lt;/FONT&gt;&amp;nbsp;for the fourth event), and Assume&amp;nbsp;the following "If&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s5-&amp;nbsp; e1&amp;gt;30&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;(hence&amp;nbsp;&lt;FONT face="courier new,courier"&gt;new_event=1&lt;/FONT&gt;&amp;nbsp;for the firth event). Then if the next evaluation "If&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s6-e5&amp;lt;=30&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;(hence&amp;nbsp;&lt;FONT face="courier new,courier"&gt;new_event=0&lt;/FONT&gt;&amp;nbsp;for the sixth event). This kind of evaluation is what I desire.&lt;STRONG&gt; That is the rule.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would you decide this case?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Your other suggestion involving "&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s2-e4&amp;gt;30&lt;/FONT&gt;&lt;/STRONG&gt;"&amp;nbsp;is questionable because this condition can never be true, given that always s2&amp;lt;e4.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The above expression was a typing Error, its impossible.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first rule is likely to encounter many observations in between with less than 30 days and leave them as (new_event=0) Eg assume there are ten (event=1) separated from each other by 20 days which totals to 200 days. The First rule will leave them as (new_event=0) which is the problem am having while the second rule will partition them into may be five episodes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will be glad to receive your assistance for this rule to be implemented.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 07 Oct 2018 15:30:27 GMT</pubDate>
    <dc:creator>DavidsM</dc:creator>
    <dc:date>2018-10-07T15:30:27Z</dc:date>
    <item>
      <title>RESTRICTING  RECURRENCE STATUS BASED ON TIME TIME INTERVALS BETWEEN EVENTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/501332#M133656</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello community members,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working with longitudinal data with several events of interest and would like to calculate the duration between recurrent events, with recurrence&amp;nbsp;of the event being possible several times per individual. Although some individuals have many recurrent events, the standard number of days must elapse before a next event can be considered a true recurrent event (i.e. some events are just continuation of a previous event if they occur within 30 days after the previous one and I want to turn them into non-events in my data. I have calculated the time that has elapsed between events but since some individuals have many non-events and also many events with different intervals in between, It has become hard for me get the exact data I want for the recurrent variable (Status).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried a number of expressions that can bring out my desired variable but not yet successful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example of the data set that I have is below, where study_id is the unique participant identifier, Startdate is the date of visit, and event1 is the events of interest.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;study_id&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;Startdate&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;Event1&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;1001&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;1-Jan&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;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BODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The variable I want for recurrence is as follows;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I created the variable StopDate using the StartDate variable (i.e using Date of visit data) with purpose of calculating the time interval between the visits (Variable &lt;STRONG&gt;TimeDiff&lt;/STRONG&gt; below in the table is interval between visits). The problem is that the time difference must be at least 30 days from a given observation (event=1) to another (event=1) in order for the second to be a recurrent event. As you see below the 2nd and 3rd events occur before 30 days elapse (i.e occur at 9 days and 8 days, respectively) and are therefore not considered as recurrent but continuation of the first one. But event on 4th March occurs after more than 40 days from the first event and I consider it as a true recurrent event. The study ends on 31-Dec for all individuals. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;See desired Table below.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;SPAN&gt;study_id&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;SPAN&gt;Startdate&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD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p;nbsp; &amp;nbsp; 365&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I request to be assisted on how to deal with those events occurring after a cumulative period of more than 40 days from the previous (event=1) so that I can selectively turn them into (Recurrence=1) while keeping both (events=1 and Event=0) occurring before 30 days elapse as (Recurrent=0).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I will be glad to receive your assistance.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 05:01:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/501332#M133656</guid>
      <dc:creator>DavidsM</dc:creator>
      <dc:date>2018-10-04T05:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: RESTRICTING  RECURRENCE STATUS BASED ON TIME TIME INTERVALS BETWEEN EVENTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/501532#M133722</link>
      <description>&lt;P&gt;Are those dates actual SAS date values?&lt;/P&gt;
&lt;P&gt;Also what would you expect the resulting data set to look like?&lt;/P&gt;
&lt;P&gt;And by "The study ends on 31-Dec for all individuals" do you mean within a calendar year? I ask because the data shown seems to strongly imply that you have multiple years of data when a start date is "31 Dec" and end date is "31 Jan". I also wonder how you are calculating the TIMEDIFF as generally we get 31 days between 31 Dec and the following 31 Jan, and $ Feb to 24 Apr would be more like 79 than 20.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 15:21:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/501532#M133722</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-04T15:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: RESTRICTING  RECURRENCE STATUS BASED ON TIME TIME INTERVALS BETWEEN EVENTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/501596#M133756</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/203872"&gt;@DavidsM&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;study_id&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Startdate&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;StopDate&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;Event&amp;nbsp;&amp;nbsp;&amp;nbsp; TimeDiff&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Recurrence&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&lt;SPAN&gt;1001&lt;/SPAN&gt;&lt;/P&gt;
&lt;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p; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Just to add: These first three&amp;nbsp;rows alone suggest &lt;EM&gt;three&lt;/EM&gt; different formulas for TimeDiff.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 17:09:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/501596#M133756</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-04T17:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: RESTRICTING  RECURRENCE STATUS BASED ON TIME TIME INTERVALS BETWEEN EVENTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/501669#M133796</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="login-bold"&gt;Hell&lt;FONT color="#000000"&gt;o&amp;nbsp;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733" target="_self"&gt;FreelanceReinhard&lt;/A&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your comments;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached a word document with screenshots of the variables I have so far created and their description as well as the kind of variable I want to create.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will be glad for your assistance.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 19:29:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/501669#M133796</guid>
      <dc:creator>DavidsM</dc:creator>
      <dc:date>2018-10-04T19:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: RESTRICTING  RECURRENCE STATUS BASED ON TIME TIME INTERVALS BETWEEN EVENTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/501676#M133800</link>
      <description>&lt;P&gt;Hello ballardw;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your comments;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had not used the real dates in the data but I have attached the word document containing&amp;nbsp;screenshots of the variables I have so far created and their description as well as the kind of variable I want to create.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will be glad for your assistance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 19:44:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/501676#M133800</guid>
      <dc:creator>DavidsM</dc:creator>
      <dc:date>2018-10-04T19:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: RESTRICTING  RECURRENCE STATUS BASED ON TIME TIME INTERVALS BETWEEN EVENTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/501700#M133806</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/203872"&gt;@DavidsM&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the attached material.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's try to simplify things a bit and focus on &lt;STRONG&gt;events&lt;/STRONG&gt; and the dates on which events occur (or start).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's not impossible, but &lt;EM&gt;very&lt;/EM&gt; difficult for SAS to read data from screenshots. So, let's create some test data from scratch:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create test data */

data have;
call streaminit(2718281);
do id=1 to 2;
  date='01JAN06'd;
  do _n_=1 to 15;
    date+rand('integer',40); /* use "date+ceil(rand('uniform',40));" with older SAS releases */
    event=rand('bern',0.6);
    output;
  end;
end;
format date yymmdd10.;
run;

/* Add variable NEW_EVENT */

data want(drop=evdate);
retain evdate;
set have;
by id date;
if first.id then evdate=-99999;
new_event=event;
if event then do;
  if .&amp;lt;date-evdate&amp;lt;=30 then new_event=0;
  else evdate=date;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The second data step above creates a variable NEW_EVENT, which equals EVENT except in cases where a new event had occurred &amp;lt;=30 days before. In these cases NEW_EVENT is set to 0 (while EVENT=1).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you can apply a similar logic to your real data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note that you can create much larger test datasets by increasing the end values of the two DO loops. You can also play around with the parameters of the RAND function calls and the seed value 2718281. Large test datasets can be useful to compare the results of different algorithms (using PROC COMPARE with the corresponding WANT datasets) because they are likely to cover many if not all relevant cases.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 22:53:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/501700#M133806</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-04T22:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: RESTRICTING  RECURRENCE STATUS BASED ON TIME TIME INTERVALS BETWEEN EVENTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/501778#M133835</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you FreelanceReinhard for your assistance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code has helped me to convert some of the observations into what I want for example (events=1) and time less than 30 days have been converted to (new-event=0) very well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, one more problem remains. Some observations are following each other with (event=1)&amp;nbsp; but each having less than 30 days, some with (event=1) like that immediately following the true recurrent event qualifying for conversion into (new_vent=0) because they have total time elapsed less than 30 days from the previous true recurrence while one qualifying&amp;nbsp;to remain as (new_event=1), because it happens after cumulative time of&lt;STRONG&gt; (10+10+10+10=40 days) &lt;/STRONG&gt;even though it as an individual observation&amp;nbsp;it has has 10 days.&amp;nbsp;&amp;nbsp;It was also turned into&lt;STRONG&gt;&amp;nbsp;(new_event=0) because it alone has 10 days BUT since its cumulative&amp;nbsp;days from the first (new_event=1) i&lt;/STRONG&gt;s 40 days it should be&lt;STRONG&gt; (new-event=1)&lt;/STRONG&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;see an example of this scenario below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;event&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Days&amp;nbsp; &amp;nbsp; &amp;nbsp; new-event&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 37&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;FONT color="#000000"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT face="arial black,avant garde"&gt;&lt;STRONG&gt; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;50&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT face="arial black,avant garde"&gt;&lt;STRONG&gt;&amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;The highlighted observations have (event=1) and were also turned into (event=0) because they less than 30 days of duration. But because&amp;nbsp;they recur after more than 40 days from the previously true event i.e (new-event=1), I should convert them also into (new_event=1).&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;SPAN&gt;&lt;STRONG&gt;In brief the conversion should be based on any of the two; 1) either time elapsed between events or on the duration of that single event in this case the days for each observation.&amp;nbsp; Or based on days between observations in the column per subject.&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;SPAN&gt;I really have a problem with those events in between which have shorter duration&lt;STRONG&gt; (less than 30 days but the intervals between&amp;nbsp;them if added eg 10+10+10+10 =40) the fourth one should be turned to (new_event=1) and those (events=1) eg 10+10=20 days) should remain (events=0) till another one follows them to make total elapsed&amp;nbsp;time since the true (new_event=1) more than 30 days.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;SPAN&gt;&lt;STRONG&gt;I will be glad for receive your assistance on this issue once more.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;SPAN&gt;&lt;STRONG&gt;Thanks in advance.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Oct 2018 08:23:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/501778#M133835</guid>
      <dc:creator>DavidsM</dc:creator>
      <dc:date>2018-10-05T08:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: RESTRICTING  RECURRENCE STATUS BASED ON TIME TIME INTERVALS BETWEEN EVENTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/501853#M133864</link>
      <description>&lt;P&gt;The algorithm I proposed does not use a concept of event duration. It is basically aimed at point events. An application to extended events (like adverse events in a clinical trial) is possible, but only the onset date would be used, disregarding duration.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Therefore, your interpretations of NEW_EVENT involving durations (e.g. "It was also turned into (new_event=0) because it alone has 10 days" or "turned into (event=0) because they less than 30 days of duration") are not supported by the program code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, let's try and introduce the concept of event duration into the algorithm:&lt;/P&gt;
&lt;P&gt;Ideally, each event should have a start date and an end date, i.e. the first and last date the condition defining the event (e.g. headache) was present. These dates would be stored as SAS date values in numeric variables, e.g. STARTDT and ENDDT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have (or can you derive) start and end dates for each event?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can we assume that two events (for the same patient) don't overlap? Otherwise, wouldn't it make sense to merge overlapping and also adjacent events into one?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, the first three events of a patient would be characterized by six SAS date values:&lt;/P&gt;
&lt;PRE&gt;STARTDT ENDDT NEW_EVENT
  s1      e1      1
  s2      e2      ?
  s3      e3      ?&lt;/PRE&gt;
&lt;P&gt;with s1&amp;lt;=e1&amp;lt;s2&amp;lt;=e2&amp;lt;s3&amp;lt;=e3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Clearly, the first of these three events qualifies for NEW_EVENT=1. Now it should be possible to define the value of NEW_EVENT for the second event in terms of s1, e1, s2 and (perhaps) e2 (e.g. "&lt;FONT face="courier new,courier"&gt;if s2-e1&amp;gt;30 then new_event=1; else new_event=0;&lt;/FONT&gt;").&lt;BR /&gt;Similarly, the value of NEW_EVENT for the third event should be definable in terms of s1, e1, s2, e2, s3 and (perhaps) e3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Only you know the exact criteria. So, please provide these definitions. Then we can move on to the implementation.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Oct 2018 12:23:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/501853#M133864</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-05T12:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: RESTRICTING  RECURRENCE STATUS BASED ON TIME TIME INTERVALS BETWEEN EVENTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502107#M133986</link>
      <description>&lt;P&gt;Thank you so much FreelanceReinhard'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yo have described exactly the situation I have. I have copied part of your text to answer the questions you asked.&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;&lt;P&gt;Do you have (or can you derive) start and end dates for each event? &lt;STRONG&gt;Yes I have derived those StartDate and EndDate variables and they are in SAS dates format.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can we assume that two events (for the same patient) don't overlap? Otherwise, wouldn't it make sense to merge overlapping and also adjacent events into one?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The events don't overlap for example using the headache example you gave, the person cannot experience the next headache event before the first one ends BUT the second may start immediately after end of the first one like may be after a day. So in this case the expression you gave (s1&amp;lt;=e1&amp;lt;s2&amp;lt;=e2&amp;lt;s3&amp;lt;=e3) is exactly what I have.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If so, the first three events of a patient would be characterized by six SAS date values:&lt;/P&gt;&lt;PRE&gt;STARTDT ENDDT NEW_EVENT
  s1      e1      1
  s2      e2      ?
  s3      e3      ?&lt;/PRE&gt;&lt;P&gt;with s1&amp;lt;=e1&amp;lt;s2&amp;lt;=e2&amp;lt;s3&amp;lt;=e3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Clearly, the first of these three events qualifies for NEW_EVENT=1. Now it should be possible to define the value of NEW_EVENT for the second event in terms of s1, e1, s2 and (perhaps) e2 (e.g. "&lt;FONT face="courier new,courier"&gt;if s2-e1&amp;gt;30 then new_event=1; else new_event=0;&lt;/FONT&gt;").&lt;BR /&gt;Similarly, the value of NEW_EVENT for the third event should be definable in terms of s1, e1, s2, e2, s3 and (perhaps) e3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The first event must always be as you stated above (NEW_EVENT=1) even if&amp;nbsp;the person had only one event in his life. The following events are the ones I want to categorize&amp;nbsp;again&amp;nbsp; based on the criteria&amp;nbsp;of 30 days apart from each other.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note: The last event should also be&amp;nbsp;(NEW_EVENT=1)&amp;nbsp;because its possible&amp;nbsp;for the StartDate&amp;nbsp; and EndDate of the last observation to be the same (I.e if the participant is not followed up beyond the last recorded date, we consider that last event as a true event=1) and assume that same date as the Endate according to the date variables.&amp;nbsp;&lt;/STRONG&gt;&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;&lt;P&gt;Thank you very much FreelanceReinhard for introducing this concept which is exactly what I wanted.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will glad to receive your assistance.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Oct 2018 12:48:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502107#M133986</guid>
      <dc:creator>DavidsM</dc:creator>
      <dc:date>2018-10-06T12:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: RESTRICTING  RECURRENCE STATUS BASED ON TIME TIME INTERVALS BETWEEN EVENTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502121#M133995</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/203872"&gt;@DavidsM&lt;/a&gt;&amp;nbsp;for answering some of my questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You've introduced one extra rule: NEW_EVENT=1 for the last event of each patient. This will be very easy to implement using BY-group processing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also the first event is settled. Good.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, we're left with the&amp;nbsp;intermediate events of a patient, but once we have defined the rules for the second and third, chances are that they apply to the subsequent events (except the last) as well. My example, "&lt;FONT face="courier new,courier"&gt;if &lt;STRONG&gt;s2-e1&amp;gt;30&lt;/STRONG&gt; then new_event=1; else new_event=0;&lt;/FONT&gt;&lt;SPAN&gt;", was meant to help you formulate these rules.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I can just repeat:&amp;nbsp;Only &lt;EM&gt;you&lt;/EM&gt; know the exact criteria. &lt;STRONG&gt;Please provide the IF conditions in terms of s1, e1, s2 etc. that determine the value of NEW_EVENT for the second and third event&lt;/STRONG&gt; (where it is assumed that there are at least four events in total -- so the third is &lt;EM&gt;not&lt;/EM&gt; the last). Then we can move on to the implementation.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Oct 2018 14:23:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502121#M133995</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-06T14:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: RESTRICTING  RECURRENCE STATUS BASED ON TIME TIME INTERVALS BETWEEN EVENTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502146#M134010</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;FreelanceReinhard for your reply.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I think&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;("&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;if&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;s2-e1&amp;gt;30&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;then new_event=1; else new_event=0;&lt;/FONT&gt;&lt;SPAN&gt;") and the subsequent&amp;nbsp;&amp;nbsp;("&lt;FONT face="courier new,courier"&gt;if&amp;nbsp;&lt;STRONG&gt;s3-e2&amp;gt;30)&lt;/STRONG&gt;&amp;nbsp;then new_event=1; else new_event=0;&lt;/FONT&gt;") ,&amp;nbsp;&amp;nbsp;("&lt;FONT face="courier new,courier"&gt;if&amp;nbsp;&lt;STRONG&gt;s4-e3&amp;gt;30&lt;/STRONG&gt;&amp;nbsp;then new_event=1; else new_event=0;&lt;/FONT&gt;"), etc will be the IF conditions required.&amp;nbsp; &amp;nbsp;However, in case the first (event=1) is followed by for example two observations&amp;nbsp;when the (event=0) , then the third evaluation should be&amp;nbsp;("&lt;FONT face="courier new,courier"&gt;if&amp;nbsp;&lt;STRONG&gt;s2-e4&amp;gt;30&lt;/STRONG&gt;&amp;nbsp;then new_event=1; else new_event=0;&lt;/FONT&gt;").&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The IF contrition&amp;nbsp;should evaluate from the EndDate of the previous (new_event=1)&amp;nbsp; to the&amp;nbsp; start date of next (event=1)&amp;nbsp; and ignore&amp;nbsp; (event=0) but&amp;nbsp; make them remain as (new_event=0).&amp;nbsp; That is to say even if the first (new_event=1) is followed by ten observations that have (event=0) and then the Twelfth&amp;nbsp;observation has (event=1), then the IF condition should be able to evaluate&amp;nbsp;("&lt;FONT face="courier new,courier"&gt;if&amp;nbsp;&lt;STRONG&gt;s12-e1&amp;gt;30&lt;/STRONG&gt;&amp;nbsp;then new_event=1; else new_event=0;&lt;/FONT&gt;").&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note: some observations for a given participant can start with (event=0) then in the subsequent observations we encounter that scenario above that am&amp;nbsp; targeting&amp;nbsp;to work on and convert into appropriate event description.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I think that will bring out the conversion of events i desire to have. The relationship between events' EndDate and StartDate&amp;nbsp; is the main focus.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you for your continued support.&lt;/SPAN&gt;&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Oct 2018 16:11:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502146#M134010</guid>
      <dc:creator>DavidsM</dc:creator>
      <dc:date>2018-10-06T16:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: RESTRICTING  RECURRENCE STATUS BASED ON TIME TIME INTERVALS BETWEEN EVENTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502164#M134020</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/203872"&gt;@DavidsM&lt;/a&gt;&amp;nbsp;for the clarification.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Obviously, observations with EVENT=0 will have NEW_EVENT=0. Moreover, you've confirmed that they are to be ignored in the definition of NEW_EVENT for observations with EVENT=1 (which&amp;nbsp;we call "events"). Actually, the values s1, e1 etc. that I introduced referred to &lt;EM&gt;events&lt;/EM&gt; only.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We have to resolve a possible contradiction: For the third event you specify:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;"&lt;FONT face="courier new,courier"&gt;if&amp;nbsp;&lt;STRONG&gt;s3-e2&amp;gt;30&lt;FONT color="#999999"&gt;)&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;then new_event=1; else new_event=0;&lt;/FONT&gt;"&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Later you formulate the general rule&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The IF contrition&amp;nbsp;should evaluate from the EndDate of the previous (new_event=1)&amp;nbsp; to the&amp;nbsp; start date of next (event=1) ...&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Now consider a patient with &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s2-e1&amp;lt;=30&lt;/FONT&gt;&lt;/STRONG&gt; (hence &lt;FONT face="courier new,courier"&gt;new_event=0&lt;/FONT&gt;&amp;nbsp;for the second event), &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s3-e2&amp;lt;=30&lt;/FONT&gt;&lt;/STRONG&gt; and &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s3-e1&amp;gt;30&lt;/FONT&gt;&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first rule implies &lt;FONT face="courier new,courier"&gt;new_event=&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;for the third event, whereas the second rule (which is a bit vague) seems to suggest &lt;FONT face="courier new,courier"&gt;new_event=&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How would you decide this case?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(Your other suggestion involving "&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s2-e4&amp;gt;30&lt;/FONT&gt;&lt;/STRONG&gt;"&amp;nbsp;is questionable because this condition can never be true, given that always s2&amp;lt;e4.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Oct 2018 20:38:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502164#M134020</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-06T20:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: RESTRICTING  RECURRENCE STATUS BASED ON TIME TIME INTERVALS BETWEEN EVENTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502258#M134054</link>
      <description>&lt;P&gt;Thank you FreelanceReinhard for the response&amp;nbsp; about the clarification.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I have pasted your text to clarify more about the desired variable,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obviously, observations with EVENT=0 will have NEW_EVENT=0. Moreover, you've confirmed that they are to be ignored in the definition of NEW_EVENT for observations with EVENT=1 (which&amp;nbsp;we call "events"). Actually, the values s1, e1 etc. that I introduced referred to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;events&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;only.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If&amp;nbsp;&amp;nbsp;the values s1, e1 etc. that you introduced referred to&amp;nbsp;&lt;EM&gt;events&lt;/EM&gt;&amp;nbsp;only and therefore evaluating observations of (event=1) then I think the formula should evaluate (&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;if&amp;nbsp;s3-e2&amp;gt;30&lt;FONT color="#999999"&gt;)&lt;/FONT&gt;&amp;nbsp;then new_event=1; else new_event=0;&lt;/FONT&gt;&lt;SPAN&gt;"), Where&amp;nbsp; the StartDate (s3) pertains to the following (events=1) to be evaluated and the EndDate (e2)&amp;nbsp;pertains to the converted&amp;nbsp;(new_event=1).&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;In case the evaluation returns (new_event=0) the the following evaluation should disregard it and&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;STRONG&gt;evaluates the next (event=1) this time again in relation to the last known (new_event=1). This is because all (events=1) that are turned into (new_event=0) are assumed to have been also (event=0) in real settings.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;We want to assume the (event=1) observations that turn into (new_event=0) were actually (event=0) in real sense and therefore our evaluations targeting&amp;nbsp;the observations that turned into (new_event=1) and the subsequent (event=1) that remain&amp;nbsp;(new_event=1), then subsequent (event=1) that (remain new_event=1) etc. Assumption is that those (event=1) that turn into (new_event=0) were actually (event=0), then If the condition can evaluate this it will give the desired output.&lt;/STRONG&gt;&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;&lt;P&gt;We have to resolve a possible contradiction: For the third event you specify:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;"&lt;FONT face="courier new,courier"&gt;if&amp;nbsp;&lt;STRONG&gt;s3-e2&amp;gt;30&lt;FONT color="#999999"&gt;)&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;then new_event=1; else new_event=0;&lt;/FONT&gt;"&lt;/BLOCKQUOTE&gt;&lt;P&gt;Later you formulate the general rule&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The IF contrition&amp;nbsp;should evaluate from the EndDate of the previous (new_event=1)&amp;nbsp; to the&amp;nbsp; start date of next (event=1) ...&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Now consider a patient with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s2-e1&amp;lt;=30&lt;/FONT&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(hence&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;new_event=0&lt;/FONT&gt;&amp;nbsp;for the second event),&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s3-e2&amp;lt;=30&lt;/FONT&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s3-e1&amp;gt;30&lt;/FONT&gt;&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first rule implies&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;new_event=&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;for the third event, whereas the second rule (which is a bit vague) seems to suggest&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;new_event=&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The second rule may give what I expect to come out basing on your example above, because taking considering this example you have given here below&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Now consider a patient with&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s2-e1&amp;lt;=30&lt;/FONT&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;(hence&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;new_event=0&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;for the second event),&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s3-e2&amp;lt;=30&lt;/FONT&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;and&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;(&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s3-e1&amp;gt;30)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;This is what&amp;nbsp;i desire for the third event&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN style="font-weight: bold;"&gt;(&lt;/SPAN&gt;&lt;STRONG&gt;s3-e1&amp;gt;30)if the second&amp;nbsp;event(&lt;STRONG&gt;s2-e1&amp;lt;=30)&lt;/STRONG&gt;turned out to be (new_event=0&lt;/STRONG&gt;&lt;SPAN style="font-weight: bold;"&gt;)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;STRONG&gt;.&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In this case the third observation &lt;SPAN style="font-weight: bold;"&gt;(&lt;/SPAN&gt;&lt;STRONG&gt;s3-e1&amp;gt;30)&amp;nbsp;&lt;/STRONG&gt;occurs after more than 30 days from the last known (new_event=1) and therefore its a true (new_event=1) unlike the second event. &lt;STRONG&gt;This is what am desiring to get.&amp;nbsp;&lt;/STRONG&gt; And the evaluation should start again from that event afresh to evaluate the following observation in the same manner. Eg&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s2-e1&amp;lt;=30&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;(hence&amp;nbsp;&lt;FONT face="courier new,courier"&gt;new_event=0&lt;/FONT&gt;&amp;nbsp;for the second event), then next "If&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s3-e1&amp;lt;=30&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;(hence&amp;nbsp;&lt;FONT face="courier new,courier"&gt;new_event=0&lt;/FONT&gt;&amp;nbsp;for the third event), then if next evaluation "If&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s4-e1&amp;lt;=30&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;(hence&amp;nbsp;&lt;FONT face="courier new,courier"&gt;new_event=0&lt;/FONT&gt;&amp;nbsp;for the fourth event), and Assume&amp;nbsp;the following "If&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s5-&amp;nbsp; e1&amp;gt;30&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;(hence&amp;nbsp;&lt;FONT face="courier new,courier"&gt;new_event=1&lt;/FONT&gt;&amp;nbsp;for the firth event). Then if the next evaluation "If&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s6-e5&amp;lt;=30&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;(hence&amp;nbsp;&lt;FONT face="courier new,courier"&gt;new_event=0&lt;/FONT&gt;&amp;nbsp;for the sixth event). This kind of evaluation is what I desire.&lt;STRONG&gt; That is the rule.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would you decide this case?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Your other suggestion involving "&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;s2-e4&amp;gt;30&lt;/FONT&gt;&lt;/STRONG&gt;"&amp;nbsp;is questionable because this condition can never be true, given that always s2&amp;lt;e4.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The above expression was a typing Error, its impossible.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first rule is likely to encounter many observations in between with less than 30 days and leave them as (new_event=0) Eg assume there are ten (event=1) separated from each other by 20 days which totals to 200 days. The First rule will leave them as (new_event=0) which is the problem am having while the second rule will partition them into may be five episodes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will be glad to receive your assistance for this rule to be implemented.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Oct 2018 15:30:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502258#M134054</guid>
      <dc:creator>DavidsM</dc:creator>
      <dc:date>2018-10-07T15:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: RESTRICTING  RECURRENCE STATUS BASED ON TIME TIME INTERVALS BETWEEN EVENTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502261#M134056</link>
      <description>&lt;P&gt;Thanks for your decision and the detailed explanations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I think we're back at my original solution, amended by the additional rule "&lt;SPAN&gt;NEW_EVENT=1 for the last event of each patient," as we've discussed earlier:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create test data */

data have;
call streaminit(2718281);
do id=1 to 7;
  date='01JAN06'd;
  do _n_=1 to 15;
    date+rand('integer',40);
    event=rand('bern',0.6);
    output;
  end;
end;
format date yymmdd10.;
run;

/* Add variable NEW_EVENT */

data want(drop=evdate:);
do until(last.id);
  set have;
  by id date;
  if event then evdate_last=date;
end;
evdate=-99999;
do until(last.id);
  set have;
  by id date;
  new_event=event;
  if event then do;
    if .&amp;lt;date-evdate&amp;lt;=30 then new_event=0;
    else evdate=date;
  end;
  if date=evdate_last &amp;amp; event then new_event=1;
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;In the above test data IDs 3, 4, 5 and 7 are affected by the newly introduced extra rule.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please feel free to extend dataset HAVE (e.g. &lt;FONT face="courier new,courier"&gt;do id=1 to &lt;EM&gt;1000&lt;/EM&gt;;&lt;/FONT&gt;) and perform checks of the resulting dataset&amp;nbsp;WANT. If you find an observation where you're not satisfied with the value of NEW_EVENT, simply state the ID and DATE values and I'll have a look at it.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Oct 2018 19:11:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502261#M134056</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-07T19:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: RESTRICTING  RECURRENCE STATUS BASED ON TIME TIME INTERVALS BETWEEN EVENTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502371#M134106</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;SPAN class="login-bold"&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733" target="_self"&gt;FreelanceReinhard&lt;/A&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;You have really been a great advisor. I have followed the new approach you gave me and It has brought out what I expected and desired.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;So you have solved the problem. I request you if possible to modify this program in case in future I decide the last event to follow&amp;nbsp; the same rule like the events in between and not being automatically turned to (new_event=1) if its below 30 days.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;I thank you for the assistance you have given till solving this problem.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 12:23:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502371#M134106</guid>
      <dc:creator>DavidsM</dc:creator>
      <dc:date>2018-10-08T12:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: RESTRICTING  RECURRENCE STATUS BASED ON TIME TIME INTERVALS BETWEEN EVENTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502382#M134110</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/203872"&gt;@DavidsM&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You're welcome. I'm happy that I could help you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The solution &lt;EM&gt;disregarding&lt;/EM&gt;&amp;nbsp;the extra rule about the last event is exactly that in my &lt;A href="https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/501700#M133806" target="_blank"&gt;earlier post&lt;/A&gt;. To check&amp;nbsp;this assertion, you can compare the result of that shorter data step (using a large input dataset HAVE) with the result of the extended data step, but with one line commented out (and, of course, a different output dataset name, e.g. WANT0):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  *if date=evdate_last &amp;amp; event then new_event=1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PROC COMPARE should then confirm the equality of WANT and WANT0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note that the shorter data step is more efficient than the extended one&amp;nbsp;because for the extra rule (whether applied or not, i.e. with the above IF/THEN statement active or commented out) I used a second SET statement, i.e., dataset HAVE is read &lt;EM&gt;twice&lt;/EM&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 13:02:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502382#M134110</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-08T13:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: RESTRICTING  RECURRENCE STATUS BASED ON TIME TIME INTERVALS BETWEEN EVENTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502418#M134114</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;STRONG&gt;I am really so grateful for your assistance. Just so grateful and &lt;FONT size="5"&gt;so&lt;/FONT&gt; thankful to you FreelanceReinhard.&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 14:20:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RESTRICTING-RECURRENCE-STATUS-BASED-ON-TIME-TIME-INTERVALS/m-p/502418#M134114</guid>
      <dc:creator>DavidsM</dc:creator>
      <dc:date>2018-10-08T14:20:03Z</dc:date>
    </item>
  </channel>
</rss>

