I have some SAS code that needs to reference some values in a previous row. The lag function is typically how one deals with that. The issue is that the value that I grab using lag then (possibly) gets changed and the change isn't reflected in the next row. I've provided a short example but basically think of 'x' as the starting value and 'y' as the ending value and I don't want any of the intervals to be overlapping so if the starting value is <= the previous ending value I want to shift the interval over and keep repeating this process.
My output gives:
I would have expected/desired
So basically in the final row the lagged value for y is reading the original unmodified value of 4 instead of the updated value of 6. I think this is due to lag being implemented as a queue but I don't know how to tell lag to update after I change the value. I'm open to any suggestions - I'm not married to using lag here if there is another way around the issue.