Dear All, I have this dataset,
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(id year staryear endyear)
.  8 . .
.  9 . .
1 10 1 .
. 11 . .
. 12 . 1
. 13 . .
. 14 . .
2  9 1 .
. 10 . .
. 11 . .
. 12 . .
. 13 . 1
. 14 . .
end
How can I keep the observations between staryear and endyear for each id? The following is what I want.
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(id year staryear endyear)
1 10 1 .
1 11 . .
1 12 . 1
1 13 . .
1 14 . .
2  9 1 .
2 10 . .
2 11 . .
2 12 . .
2 13 . 1
end
Thanks in advance.