Hi SAS Users, I have been having an issues with medication use overlapping. My data looks like this: Patient_ID Medication start_dt End_dt Tom A 8/29/2013 9/28/2013 Tom A 10/3/2013 11/2/2013 Tom A 11/4/2013 12/4/2013 Tom A 12/7/2013 1/6/2014 Tom A 1/22/2014 8/26/2014 Tom B 8/29/2013 9/28/2013 Tom B 10/1/2013 11/25/2013 Tom B 12/7/2013 1/6/2014 Tom B 1/12/2014 2/11/2014 Tom B 2/16/2014 3/18/2014 Tom B 3/30/2014 4/29/2014 Tom B 5/13/2014 7/7/2014 Tom E 9/6/2013 11/2/2013 Tom E 2/7/2014 2/14/2014 Jerry C 8/5/2013 12/27/2013 Jerry C 1/2/2014 5/23/2014 Jerry C 5/29/2014 7/27/2014 Jerry D 3/21/2014 6/14/2014 Jerry D 6/16/2014 8/8/2014 Jerry E 6/7/2014 6/19/2014 Joe A 3/28/2016 5/27/2016 Joe A 6/2/2016 7/28/2016 Joe A 8/3/2016 9/2/2016 Joe A 9/7/2016 11/5/2016 Joe A 11/7/2016 12/7/2016 Joe A 12/12/2016 1/11/2017 Joe A 1/13/2017 2/12/2017 Joe A 2/15/2017 4/15/2017 Joe C 7/25/2016 8/24/2016 Joe C 8/26/2016 9/25/2016 Joe C 10/10/2016 12/7/2016 Joe C 12/12/2016 1/11/2017 Joe C 1/20/2017 3/22/2017 Joe D 3/28/2016 5/28/2016 Joe D 6/6/2016 11/5/2016 Joe D 11/7/2016 12/7/2016 Joe D 12/12/2016 4/22/2017 Joe E 5/12/2016 5/15/2016 So each patient were prescribed medication at least three of the five Medication A, B, C, D, E. My goal is to identify patients with patients with at least three overlapping medications. Overlapping medication is defined if one medication's start_dt and end_dt interacts with the other medication's start_dt and end_dt. For example, patient Tom's A prescription fill runs from 08/29/2013 - 9/28/2013; Tom's B prescription fill runs from 08/29/2013-9/28/2013; Tom's E prescription fill runs from 09/06/2013-11/02/2013. Hence, Tom's all three medication overlapped and should be flagged. The end product table should looks like this Patient_ID flag_3_meds Tom 1 Jerry 1 Joe 1 Note, a patient must have at least three medication overlaps, if A overlaps B, B overlaps C, but A doesn't overlap C, then the flag_3_meds=0. So what is a functional algorithm to generate the flag_3_meds indicator?
... View more