In relation to performing a cox regression, I am looking for a way to
identify spells in a dataset containing longitudinal panel data of 48
week-by-week registrations on absenteeism from work.
The dataset is in wide format. For each participant(=id) there are 48
variables (one per week) containing either the value 0 (=working) or
the value 1 (=absent from work). The week-by-week variables are named
consecutively w1, w2, w3, ... w48, as illustrated below:
id w1 w2 w3 w4 w5 w6 ..... w48
1 1 1 1 0 0 0 0
2 1 0 0 0 0 0 0
3 1 1 1 1 1 0 0
4 0 0 0 0 0 0 0
...
102 1 1 1 1 0 0 0
I am interested in determining when a participant has had a spell of
four consecutive weeks working - so in my dataset I want to identify
spells of 4 consecutive 0's, when combing through the variable w1 to
w48 - and I want to generate two new variables: 'success' describing
if the participant has had such a spell (values 0 or1), and
'successtime' denoting the first week of the identified spells (values
1 to 45).
I have tried to use the command -spell- to achieve this, but with no
success. Does anyone have a solution to this problem?
Best regards
Morten Vejs Willert
*
* 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/