Dear Edwin,
This is an excellent suggestion! Thanks a lot!
Greetings,
Thomas
-----Urspr�ngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]]Im Auftrag von Edwin Leuven
Gesendet: Freitag, 3. September 2004 14:45
An: [email protected]
Betreff: Re: st: counting the time of being in a specific state
On Fri, 3 Sep 2004, Edwin Leuven wrote:
>> id state year count
>> 101 4 1994 1
>> 101 4 1995 2
>> 101 4 1996 3
>> 101 3 1997 1
>> 102 1 1994 1
>> 102 1 1995 2
>> 102 2 1996 1
>> 102 3 1997 1
>> 103 4 1994 1
>> 103 2 1995 1
>> 103 4 1996 1
>
>
> bysort id state (year): g count = _n
i guess i was too quick: 103 poses a complication
. bysort id: g x= sum(s!=s[_n-1])
. bysort id x: g count = _n
should work
ed.
*
* 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/
*
* 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/