<>
-egen- happily accepts expressions for some of its functions, so let`s try
and use that...
***
clear*
input Id spell begin end status:mylabel , auto
1 1 12 14 empl
1 2 15 46 unempl
1 3 47 52 sick
1 4 59 66 unempl
1 5 70 80 empl
1 6 81 88 unempl
1 7 89 105 empl
2 1 14 21 unempl
2 2 55 59 sick
2 3 61 109 empl
2 4 110 115 unempl
2 5 116 200 empl
end
compress
bys Id: gen byte newspell=sum((status[_n-1]==1)*(_n!=1))
bys Id newsp: egen window=total((begin-6)*(_n==_N)*(_n!=1))
bys Id newsp: /*
*/egen weeks=total((status==2)*/*
*/(begin<=window)*(end>=window)*/*
*/(end-window))
l, sepby(Id news)
***
HTH
Martin
_______________________
----- Original Message -----
From: <[email protected]>
To: <[email protected]>
Sent: Wednesday, May 27, 2009 11:22 PM
Subject: st: how to calculate employment history - panel data
I have the following panel dataset:
Id spell begin end status
1 1 12 14 empl
1 2 15 46 unempl
1 3 47 52 sick
1 4 59 66 unempl
1 5 70 80 empl
1 6 81 88 unempl
1 7 89 105 empl
2 1 14 21 unempl
2 2 55 59 sick
2 3 61 109 empl
2 4 110 115 unempl
2 5 116 200 empl
I want now to calculate for each spell and person how many weeks the
person has been e.g. unemployed during the past 31 weeks (6 month) when
he/she enters employment.
The problem is not to calculate the entire weeks spent in unemployment
but only the number of weeks during a fixed period of time.
Any help or hint would be welcome.
Thanks
____________________________________________________________________
Neu: WEB.DE FreeDSL Komplettanschluss mit DSL 6.000 Flatrate und
Telefonanschluss für 17,95 Euro/mtl.!* http://produkte.web.de/go/02/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/