Creating duration of marriage variable
I am trying to create a variable denoting duration of current marriage (years). The only wave with information on year of marriage is wave b. I am therefore attempting to create a variable with years of marriage which, in each year, gives the current year - year of marriage, provided that the individual is still married. I also want to include years married for individuals who are not married at the start of the bhps sampling, but marry between 1991-2008.
I have attempted to do this with the following Stata codes:
use variables lmary (from wave b - bmarriag), mastat and mlchy4 (from indresp files waves a-r and c-r)
by pid (wave), sort: replace lmary = lmary[_n-1] if lmary >= .
by pid (wave), sort: replace lmary = lmary[_n+1] if lmary >= .
by pid (wave), sort: replace mlchy4 = mlchy4[_n-1] if mlchy4 >= .
create variable that will give years married when 2-digit year of marriage (lmary) is subtracted from it
gen yy1900 = year - 1900
drop if individual was married before 1991 but is not married at the start of the bhps (1991)
drop if lmary<1991&lmary!=.&mastat!=1&wave==1
create years married variable for those who became married over the sample
gen yearsmarried = (year - mlchy4) if mastat==1
recode missing years married observations for those who were married before the sample, provided they are still married
if mastat==1 recode yearsmarried .=(yy1900-lmary)
However, Stata reports error: invalid name
Could someone please let me know what I am doing wrong and if there is a better/simpler way for me to create this variable? Thank you.
#2 Updated by Victoria Nolan over 4 years ago
- Status changed from New to Feedback
- Assignee changed from Alita Nandi to Harini Annadanam
- % Done changed from 0 to 80
- Private changed from Yes to No
Many thanks for your enquiry. In the first instance, please could I direct you to the following dataset, accessible from the UK Data Service:
British Household Panel Survey Consolidated Marital, Cohabitation and Fertility Histories, 1991-2009
I hope this helps with your query, but please do ask if we can help with anything else.
Also - your request seems to have been duplicated in our user forum - I'll just check that the other post is a copy and then remove it.
Best wishes, Victoria
#3 Updated by Harini Annadanam over 4 years ago
Thank you very much for your help - the dataset you have guided me towards is exactly what I need. I just have one small question about this dataset, however. There appear to be some marriages which have an end_ value of 6, indicating that they are currently together, but the stop_date_ appears to be before 2008, indicating a termination of the marriage before the panel closed. Could you shed some light on this for me, and provide some guidance for estimating the duration of a marriage in each wave?
#4 Updated by Victoria Nolan over 4 years ago
One possibility is that the cases that you have cited dropped out of the panel before 2008 and the stop_date is the last date of interview: you could check this in the data/ documentation.
If this does not provide you with an answer, we can put you in touch with the person who created this dataset and hopefully they would be able to help you further. Please let me know if you would like us to do this.
Best wishes, Victoria.