Hi, I have repeated assessments that the number of non-missing values varies across participants. I need to a) restructure the data such that an IV aligns with a DV at the next observation that is not missing and b) create a new variable that counts the lag between observations. For example, if I start with data like this: ID IV DV 1 . . 1 1 3 1 . . 1 2 4 1 3 5 1 . . 1 2 3 2 2 3 2 . . 2 4 5 I would like to end up with data like the following: ID IV DV Lag 1 . . . 1 1 4 2 1 . . . 1 2 5 1 1 3 3 2 2 2 5 2 Thank you!
... View more