Hello
I have some schooling data from which I am trying to create a retrospective panel of schooling history.
The schooling data has information on
1. Current age
2. Age at entry in school
3. Age at drop out (if dropped)
From this information I can create new variables that are
1. Year of entry in school
2. Year of exit from school (this will be equal to year of survey for those still in school at time of survey)
I want to be able to expand my data in a way that creates multiple observations for each individual wherein they enter the sample when they enter school or turn 6 (whichever is sooner) (say 2000) and exit when they turn 18 (say 2012).
1. For someone who stays in school from 6 to 18 I want a variable called enrolled that is "1" for all years between 2000 and 2012.
2. For someone who enters school at 6 and drops out at 10, I want the variable enrolled to be "1" for 2000-2004 and "0" for 2005-2012.
For children who are younger than 18 at the time of the survey they are in the panel from the time they are 6 till the survey year. Same rules as above apply in creating 0/1 enrolled variable. I also have some children who never enrolled in school so their enrolled variable will be counted as "0" for all the years between 6 and 18 (or age at survey, whichever is lower)
How can I use the
(or any other command) to change my data is such a way to make this retrospective panel?
I really appreciate any help I can get on this!
An example of what my data looks like
I have some schooling data from which I am trying to create a retrospective panel of schooling history.
The schooling data has information on
1. Current age
2. Age at entry in school
3. Age at drop out (if dropped)
From this information I can create new variables that are
1. Year of entry in school
2. Year of exit from school (this will be equal to year of survey for those still in school at time of survey)
I want to be able to expand my data in a way that creates multiple observations for each individual wherein they enter the sample when they enter school or turn 6 (whichever is sooner) (say 2000) and exit when they turn 18 (say 2012).
1. For someone who stays in school from 6 to 18 I want a variable called enrolled that is "1" for all years between 2000 and 2012.
2. For someone who enters school at 6 and drops out at 10, I want the variable enrolled to be "1" for 2000-2004 and "0" for 2005-2012.
For children who are younger than 18 at the time of the survey they are in the panel from the time they are 6 till the survey year. Same rules as above apply in creating 0/1 enrolled variable. I also have some children who never enrolled in school so their enrolled variable will be counted as "0" for all the years between 6 and 18 (or age at survey, whichever is lower)
How can I use the
Code:
expand
I really appreciate any help I can get on this!
An example of what my data looks like
PID | Age | Age_Entry | Age_exit | Year Entry | Year Exit | Year Survey | Remarks |
1 | 10 | 6 | 10 | 2008 | 2014 | 2014 | 1 throughout [never dropped out] |
2 | 12 | 5 | 10 | 2007 | 2012 | 2014 | 1 from 2007-2012, 0 from 2013-2014 [dropped out] |
3 | 10 | 6 | 6 | 2010 | 2010 | 2014 | 0 throughout from 2010-2014 [never enrolled] |
4 | 20 | 6 | 16 | 2000 | 2010 | 2014 | 1 from 2000-2010 0 from 2011-2012 AND drops from sample after 2012 (when becoming 18) [dropped out] |
Comment