Hello,
I'm seeking help to create a biographical file for survival analysis. My database concerns women, and I'm particularly interested in maternity. My goal is to segment each woman's biography into multiple lines, so that there is a line for each age group (e.g., 15-16 years, 16-17 years, ..., up to 49-50 years) starting from age 15 up to age 50 at the time of the survey. In my database, I have the woman's age at the time of the survey as well as the age at which she gave birth to each child. I aim to create as many lines for each identifier (ID) as there are one-year age groups, starting from age 15 up to 50 years (or the age at the time of the survey). All respondents are at least 15 years old. If the age at the time of the survey is less than 50 years, it will be kept as the upper limit of the last age group; otherwise, it will be kept at 50 years.
Thank you in advance for your assistance.
I tried with this code, but there is an error message like using required
gen age_mere = .
qui foreach age_mere of numlist 15/50 {
replace AGEDC = cond(AGEDC >= 50, 50, AGEDC)
replace age_mere = `age_mere' if `age_mere' <= AGEDC
keep Matricule age_mere
append
}
save "fichier_long2.dta", replace * Merge fichier_long2 and fichier_long datasets in Stata use "fichier_long2.dta", clear sort Matricule age_mere use "fichier_long.dta", clear sort Matricule age_mere merge 1:1 Matricule age_mere using "fichier_long2.dta", keepusing(age_mere) nogenerate save "long3.dta", replace
I'm seeking help to create a biographical file for survival analysis. My database concerns women, and I'm particularly interested in maternity. My goal is to segment each woman's biography into multiple lines, so that there is a line for each age group (e.g., 15-16 years, 16-17 years, ..., up to 49-50 years) starting from age 15 up to age 50 at the time of the survey. In my database, I have the woman's age at the time of the survey as well as the age at which she gave birth to each child. I aim to create as many lines for each identifier (ID) as there are one-year age groups, starting from age 15 up to 50 years (or the age at the time of the survey). All respondents are at least 15 years old. If the age at the time of the survey is less than 50 years, it will be kept as the upper limit of the last age group; otherwise, it will be kept at 50 years.
Thank you in advance for your assistance.
I tried with this code, but there is an error message like using required
gen age_mere = .
qui foreach age_mere of numlist 15/50 {
replace AGEDC = cond(AGEDC >= 50, 50, AGEDC)
replace age_mere = `age_mere' if `age_mere' <= AGEDC
keep Matricule age_mere
append
}
save "fichier_long2.dta", replace * Merge fichier_long2 and fichier_long datasets in Stata use "fichier_long2.dta", clear sort Matricule age_mere use "fichier_long.dta", clear sort Matricule age_mere merge 1:1 Matricule age_mere using "fichier_long2.dta", keepusing(age_mere) nogenerate save "long3.dta", replace
Comment