Dear Statalisters,
I want to generate a variable that counts the duration in some state. My data
looks like this:
id start end state next_state
1 1 60 1 2
1 61 72 2 3
1 73 204 3 .
2 1 60 2 1
2 61 65 1 1
2 66 67 1 1
2 68 69 1 3
2 70 204 3 .
If the state does not change (as for id 2 from 61 to 69) I want the new
variable to be missing for all but one line. Therefore
gen duration = end - start + 1 if state != next_state
works from some of the spells. But what will work for the spells that are
split over several lines?
Regards
Henrik Lindegaard
Research Associate
AKF, Institute of Local Government Studies - Denmark
Nyropsgade 37, DK-1602 Copenhagen V
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/