Hello SAS Community, I need help creating a variable that flags if a person was tested during an encounter and if they were not tested during the encounter but tested during a previous encounter within 12 months it still flags the encounter as tested. I have a dataset of multiple encounters by patient ID. It includes the admission date (adm_date) of the encounter and if the patient (patient_mrn) was tested (tested) for a disease during that encounter or not. It is possible a patient would not have been tested during a current encounter because they were seen and tested during a previous encounter within 12 months. If that is the case, then I want to flag the current encounter as tested because it meets the testing definition (new variable = tested_12). I have a variable if tested (Tested) during the encounter and another variable if the current visit is within 12 months of the previous visit (visit12mo). I need to create the tested_12 variable as described above. Here is an example of the data structure and the variable I need to create (tested_12) and how it should look afterwards. Any help is appreciated! PATIENT_MRN ADM_DATE Tested Visit12mo Tested_12 10521 7/21/2016 0 0 0 10764 7/5/2013 0 0 0 10764 5/1/2015 1 0 1 10764 1/21/2016 0 1 1 100002 12/27/2012 1 0 1 100088 1/2/2014 1 0 1 100293 10/16/2013 1 0 1 100293 5/15/2015 0 0 0 100293 5/18/2015 1 1 1 100293 7/31/2015 0 1 1 100369 3/25/2017 0 0 0 109825 8/28/2016 0 0 0 600563 8/10/2012 1 0 1 1000063 10/23/2018 1 0 1 1000083 5/20/2015 1 0 1 1000262 10/30/2017 0 0 0 1000270 1/5/2012 0 0 0 1000647 8/22/2018 0 0 0 1086737 3/28/2014 0 0 0 20000039 6/15/2015 1 0 1 100000486 3/20/2014 0 0 0 100000486 4/14/2014 0 1 0 167000635 8/2/2018 0 0 0 167000635 11/12/2018 0 1 0 190000370 2/25/2016 0 0 0 190000370 10/20/2016 1 1 1 190000370 12/26/2016 0 1 1 190000370 1/8/2017 0 1 1 190000370 4/8/2017 0 1 1 190000370 6/16/2017 0 1 1 190000370 9/11/2017 0 1 1 190000370 9/22/2017 0 1 1 190000370 2/14/2018 0 1 0 190000370 6/1/2018 0 1 0 210000242 8/24/2015 0 0 0 500000243 12/2/2012 1 0 1 500000506 10/6/2012 1 0 1 600000248 10/2/2012 1 0 1 600000248 6/5/2015 0 0 0 1670000502 3/14/2013 0 0 0 1670000502 11/15/2014 0 0 0 1670000502 11/15/2014 0 1 0 1670000502 12/1/2014 1 1 1 1670000502 12/8/2014 0 1 1 1670000502 6/25/2015 1 1 1 3100000238 12/30/2014 1 0 1 3100000238 7/30/2015 0 1 1 3100000238 1/27/2016 0 1 0 3100000238 7/7/2016 0 1 0
... View more