Custom function to create sequential index variable in longitudinal data
This is probably very basic but I’m having a hard time finding an answer to my question in existing posts. I’m working with longitudinal data and need to create a sequential index variable that represents the order of each observation within a repeated ID variable. For example, I want my data to look like this: