Hello everyone! I am working with a large dataset of medical claims trying to see how many of my patients are getting skin cancer treated within 4 months of diagnosis. So for each patient, I only want to keep observations that contain biopsied lesion code (1) and skin cancer code (2) if they are within 4 months of each other. Here’s an example of the data set: Patient ID Diagnosis Date 1 1 2012/3 1 2 2012/5 1 2 2012/5 1 2 2012/5 1 1 2013/4 1 1 2014/5 1 1 2014/6 1 2 2014/10 2 1 2012/6 2 1 2013/6 2 1 2014/6 2 1 2014/8 2 1 2015/6 3 1 2013/5 3 1 2013/6 3 2 2013/8 3 1 2015/2 3 2 2015/8 The final data set would look something like this: Patient ID Diagnosis Date 1 1 2012/3 1 2 2012/5 1 2 2012/5 1 2 2012/5 1 1 2014/6 1 2 2014/10 3 1 2013/5 3 1 2013/6 3 2 2013/8 Not all biopsied lesions are connected to a skin cancer, which is why I am having difficulty dropping unwanted observations. If anyone could help write this code, I would really appreciate it! Thank you.
... View more