I am working with the Birth Recode survey of the Demographic and health surveys. It has individual panel data on women's birth histories -- includes unique id for the mother (uid), year of birth of the mother, each child (yobchild), birth order of the child (bidx), sex of the child (b4) etc. It basically has all of the mother's birth's recorded as a panel. IE mother 1 has child 1 in year 1972 with sex female, mother 1 had child 2 in year 1974 with sex male etc.
I wanted to create a dummy that identifies if the mother had her first child in the 1980s and keep that on until the survey in the 90s. I wrote the following code but it does not take into account children who are born after the first child.
Code:
gen jan180 = 0 replace jan180 = 1 if yobchild >= 1980 & bidx == 1 // first child was born after 1980 Jan where bidx is birth order, yobch is the year of birth of the child
My question is, how do I replace jan180 == 1 for the subsequent children (bidx 2-10) but conditional on the fact that the mother's first child was born in 1980? This variable would then be indicative of the mother being fertile only after Jan 1980.
Thank you!
Lori
0 Response to Generating an ID based on multiple variables
Post a Comment