Hi thanks for the suggestion for the data structure and management, It was really helpful with the data set. Can you explain the lag function a little bit i am alittle confused. Maybe i also did not present my question as clearly as i wanted as well. From your suggestions this is where i am at now . I sorted the data for mbr_id and fill_date and i created a flag for those who have suboxone and opioid. From here how would i use the lag function to calculate if the opioid claim is rejected if its 30 days +days supply of my last suboxone fill? thanks for all the help it, ive learned alot Have mbr_id fill_date days sub_flag 1 06Jan2018 15.000 suboxone 1 20Jan2018 15.000 suboxone 1 03Feb2018 15.000 suboxone 1 23Feb2018 3.000 opioid 1 24Feb2018 15.000 suboxone 1 24May2018 7.000 suboxone 2 03Apr2018 5.000 suboxone 2 07Apr2018 30.000 suboxone 2 02May2018 30.000 opioid want mbr_id fill_date days sub_flag reject_flag 1 06Jan2018 15.000 suboxone 1 20Jan2018 15.000 suboxone 1 03Feb2018 15.000 suboxone 1 23Feb2018 3.000 opioid 1 1 24Feb2018 15.000 suboxone 1 24May2018 7.000 suboxone 2 03Apr2018 5.000 suboxone 2 07Apr2018 30.000 suboxone 2 02Sep2018 30.000 opioid 0
... View more