Hi, I'm working with longitudinal data on patients that may have two types of infections (X & Y). I want to create a new variable for patients that have any "Infection Y" at any time after an "Infection X" event. The interval variable is in months. I have tried a lot of different things, but can't seem to get any to work. Please, if you have any advice, please let me know as I am very frustrated 🙂 Thank you! Here is what my dataset looks like: ID INTERVAL INFECT_X INFECT_Y 1 1.1 1 0 1 1.4 0 0 1 1.5 0 1 2 2.4 0 1 2 2.6 1 0 3 1.6 0 1 3 1.9 1 0 3 2.0 0 1 4 2.2 0 0 4 2.4 0 0 Here is what I want it to look like: ID INTERVAL INFECT_X INFECT_Y NEWVAR 1 1.1 1 0 1 1 1.4 0 0 1 1 1.5 0 1 1 2 2.4 0 1 0 2 2.6 1 0 0 3 1.6 0 1 1 3 1.9 1 0 1 3 2.0 0 1 1 4 2.2 0 0 0 4 2.4 0 0 0 Also, note that an Infect_Y can occur before the Infect_X (ID #3), as long as another infect_Y occurs again after infect_X, it counts. Also, the infections are not always consecutive, there can be a long time between them. I appreciate any advice, thanks!
... View more