Hi all,

I have a data looks as below:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str1 id byte(time iv)
"a" 1 10
"a" 2 20
"a" 3 30
"a" 4 40
"a" 5 50
"b" 1 12
"b" 2 13
"b" 3 14
"b" 4 15
"b" 5 16
end

I want to generate the lagged value for each of the row as below. The time variable here is not really a date and the dataset is not a real panel data. I wonder if anyone knows how to realize this?


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str1 id byte(time iv ivt_1 ivt_2)
"a" 1 10  .  .
"a" 2 20 10  .
"a" 3 30 20 10
"a" 4 40 30 20
"a" 5 50 40 30
"b" 1 12  .  .
"b" 2 13 12  .
"b" 3 14 13 12
"b" 4 15 14 13
"b" 5 16 15 14
end
Thanks