Title might be misleading.
I have a longitudinal dataset with a dummy (dummy1
) variable indicating if a condition is met in a certain year, for given category
. I want this event to be taken into account for the next twenty years as well. Hence, I want to create a new dummy (dummy2
), which takes the value 1 for the 19 observations following the observation where dummy1
was 1, as well as that same observation (example below).
I was trying to create a loop with lag operators, but failed to get it to work so far.