Thank you FreelanceReinhard for the response about the clarification. I have pasted your text to clarify more about the desired variable, 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 we call "events"). Actually, the values s1, e1 etc. that I introduced referred to events only. If the values s1, e1 etc. that you introduced referred to events only and therefore evaluating observations of (event=1) then I think the formula should evaluate ("if s3-e2>30) then new_event=1; else new_event=0;"), Where the StartDate (s3) pertains to the following (events=1) to be evaluated and the EndDate (e2) pertains to the converted (new_event=1). In case the evaluation returns (new_event=0) the the following evaluation should disregard it and 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. 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 the observations that turned into (new_event=1) and the subsequent (event=1) that remain (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. We have to resolve a possible contradiction: For the third event you specify: "if s3-e2>30) then new_event=1; else new_event=0;" Later you formulate the general rule The IF contrition should evaluate from the EndDate of the previous (new_event=1) to the start date of next (event=1) ... Now consider a patient with s2-e1<=30 (hence new_event=0 for the second event), s3-e2<=30 and s3-e1>30. The first rule implies new_event=0 for the third event, whereas the second rule (which is a bit vague) seems to suggest new_event=1. 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 Now consider a patient with s2-e1<=30 (hence new_event=0 for the second event), s3-e2<=30 and (s3-e1>30) This is what i desire for the third event (s3-e1>30)if the second event(s2-e1<=30)turned out to be (new_event=0). In this case the third observation (s3-e1>30) 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. This is what am desiring to get. And the evaluation should start again from that event afresh to evaluate the following observation in the same manner. Eg If s2-e1<=30 (hence new_event=0 for the second event), then next "If s3-e1<=30 (hence new_event=0 for the third event), then if next evaluation "If s4-e1<=30 (hence new_event=0 for the fourth event), and Assume the following "If s5- e1>30 (hence new_event=1 for the firth event). Then if the next evaluation "If s6-e5<=30 (hence new_event=0 for the sixth event). This kind of evaluation is what I desire. That is the rule. How would you decide this case? (Your other suggestion involving "s2-e4>30" is questionable because this condition can never be true, given that always s2<e4.) The above expression was a typing Error, its impossible. 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. I will be glad to receive your assistance for this rule to be implemented.
... View more