Thank you. I have a wrench to add, though. What if the whole thing is dependent on a flag variable being checked. For example, below, the 3/1/22 lab result for Patient_ID 2 would not be considered in the new variable. This is the new have/want situation: Have: Patient_ID Lab_Result Lab_Flag Date 1 A Y 1/1/2022 1 B Y 2/1/2022 2 C Y 1/1/2022 2 D Y 2/1/2022 2 E 3/1/2022 3 F Y 1/1/2022 Want: Patient_ID Lab_Result Lab_Flag Date Lab_Recent 1 A Y 1/1/2022 1 B Y 2/1/2022 B 2 C Y 1/1/2022 2 D Y 2/1/2022 D 2 E 3/1/2022 3 F Y 1/1/2022 F
... View more