Dear all,
I am once again at my wits end. To supplement my panel data with additional data, I'd like to incorporate some information from a spell data set, looking like that:
To do so, I have to split up the spells by year to yield something like that:
I tried variations of this code:
gen duration = endy - beginy + 1
expand duration
bysort pid: gen x = _n - 1
gen syear = beginy + x
but always end up with unrealistic results (example above year 1991 & 1993) and/or not enough rows (1 instead of 2, 5 instead of 14)
What am I doing wrong?
I am once again at my wits end. To supplement my panel data with additional data, I'd like to incorporate some information from a spell data set, looking like that:
pid | beginy | endy | spelltyp |
201 | 1984 | 1990 | (3) lives with partner |
201 | 1990 | 1991 | (4) Partner not in Household |
201 | 1991 | 1995 | (5) single |
201 | 1995 | 2008 | (4) lives with partner |
To do so, I have to split up the spells by year to yield something like that:
pid | year | spelltyp | |
201 | 1990 | (4) partner not in household | |
201 | 1991 | (4) partner not in household |
gen duration = endy - beginy + 1
expand duration
bysort pid: gen x = _n - 1
gen syear = beginy + x
but always end up with unrealistic results (example above year 1991 & 1993) and/or not enough rows (1 instead of 2, 5 instead of 14)
What am I doing wrong?
Comment