Hi, StataListers
I am facing the following challenge. Based on the following dataset
I need to retrieve valueLagged based on lag column value, considering the panel structure.
thanks in advance.
I am facing the following challenge. Based on the following dataset
Code:
clear input byte(id date value lag) float valueLagged 1 1 1 . . 1 2 2 . . 1 3 3 . . 1 4 4 2 . 2 1 1 . . 2 2 2 . . 2 3 3 . . 2 4 4 3 . 2 5 5 1 . end . xtset id date Panel variable: id (unbalanced) Time variable: date, 1 to 5 Delta: 1 unit
Code:
. list, sepby(id ) +------------------------------------+ | id date value lag valueL~d | |------------------------------------| 1. | 1 1 1 . . | 2. | 1 2 2 . . | 3. | 1 3 3 . . | 4. | 1 4 4 2 2 | |------------------------------------| 5. | 2 1 1 . . | 6. | 2 2 2 . . | 7. | 2 3 3 . . | 8. | 2 4 4 3 1 | 9. | 2 5 5 1 4 | +------------------------------------+
Comment