Hi all, I have a tricky (for me) programming question I am hoping you can all help with. I have a dataset of clusters (subjects) of longitudinal culture results. The number of available cultures per subject varies. For the particular bacteria we are tracking, the culture results are also variable by subject, with any of the following scenarios possible: 1. All negative cultures 2. Initially negative, then all positive 3. Initially negative, then positive, then all negative again 4. Negative, positive, negative, positive (etc. in this fashion, either ending positive or negative) 5. Initially positive, then all negative 6. Initially positive, then negative, then positive again 7. Same as #4, but starting out as positive 8. All positive cultures I have a few objectives: 1. Identify those subjects with at least 1 positive culture and then all negative cultures 2. I will also want to identify those with more than 1 consecutive positive and those with more than 1 consecutive negative 3. Identify those subjects with at least 1 positive, then negative (and number of consecutive negatives) and then back to positive 4. Identify those subjects with only positive cultures 5. Identify those subjects with only negative cultures This is a bit beyond my programming skill level, so I haven't attempted too many solutions other than a couple DO and DoW loops (and I'm not even getting close to what I need). I'm attaching a simulated dataset that includes examples of all 8 scenarios described above. Really, really appreciate any ideas/solutions.
... View more