So for this data I have multiple outcomes recorded for each visit and multiple visits for each patient. I want sas to read record 1, visit 1, outcome 1(apple) and then set a baseline value. When it sees the same outcome for the same record, but a new visit, (record 1, visit 2, outcome 1(apple) it retains the value it created in visit 1. The problem that I'm having is that when it comes across a new outcome (orange) it sets the baseline of orange as the baseline of apple despite being two different outcomes. So what I want is this: record visit noformat outcome baseline 1 1 0 apple 0 1 2 1 apple 0 1 1 1 orange 1 1 2 2 orange 1 What I'm getting with my code is this: record visit noformat outcome baseline 1 1 0 apple 0 1 2 1 apple 0 1 1 1 orange 0 1 2 2 orange 0
... View more