I am using Stata 14.
My current panel dataset is in person-year-format (long). I only look at respondents who have changed from employment status A to B. I would like to know how long the respondents have been in status A. For that I have monthly spell data, in the form of 12 variables for every year, where 1 indicates being in status A and -2 not being in status A.
I am not sure how to calculate the exact spell length. My first thought was to change the dataset into person-month-format and following that simply counting consecutive months in status A.
So, like this:
However, the timing of the interviews is different in between respondents with regard to the specific month. So maybe I should consider that. I am unsure whether this is the right approach, and in particular how to include the timing of the interview in the right month.
This is my monthly spell data:
The data is of retrospective nature. So the input in 2002 relates to January to December 2001.
My current dataset looks like this:
In the end, I would like to have the last line:
My current panel dataset is in person-year-format (long). I only look at respondents who have changed from employment status A to B. I would like to know how long the respondents have been in status A. For that I have monthly spell data, in the form of 12 variables for every year, where 1 indicates being in status A and -2 not being in status A.
I am not sure how to calculate the exact spell length. My first thought was to change the dataset into person-month-format and following that simply counting consecutive months in status A.
So, like this:
Code:
reshape long d0, i(pid syear) j(month)
However, the timing of the interviews is different in between respondents with regard to the specific month. So maybe I should consider that. I am unsure whether this is the right approach, and in particular how to include the timing of the interview in the right month.
This is my monthly spell data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long pid int syear byte(d001 d002 d003 d004 d005 d006 d007 d008 d009 d010 d011 d012) 602 2000 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 602 2001 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 602 2002 -2 -2 1 1 1 1 1 1 -2 1 1 1 602 2003 1 1 1 1 1 -2 -2 1 1 1 -2 1 602 2004 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 end
My current dataset looks like this:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long pid int syear byte pmonin float age byte sex 8605 2003 2 24 1 8605 2005 2 26 1 8605 2007 2 28 1 8605 2008 4 29 1 9002 1986 3 20 1 9002 1989 2 23 1 9201 1990 3 35 0 9201 2000 2 45 0 9203 2001 2 21 0 9203 2007 3 26 0 9204 2006 3 23 1 9205 1993 2 33 1 9302 1987 3 23 0 9302 1989 3 25 0 9401 1993 4 32 0 9401 1998 2 37 0 9801 1993 4 35 0 9801 2003 5 45 0 9801 2006 6 48 0 9802 1985 3 27 1 9803 1989 2 29 1 end label values pmonin interview_month label def pmonin 2 "[2] February", modify label def pmonin 3 "[3] March", modify label def pmonin 4 "[4] April", modify label def pmonin 5 "[5] May", modify label def pmonin 6 "[6] June", modify label values sex sex label def sex 0 "fem", modify label def sex 1 "male", modify
In the end, I would like to have the last line:
pid | syear | transitioned from A to B | covariates | length of A spell |
602 | 2002 | 1 | x | 6 |
602 | 2003 | 1 | x | 8 |
602 | 2003 | 1 | x | 3 |
602 | 2004 | 1 | x | 1 |
603 | .... | |||
Comment