Hello everyone,

I have a quick question about creating compositional variables, such as the share of teenage mothers in the population. Am I doing the right thing (seen below in the code) by counting the number of mothers and teenage mothers by state and year, given that I am working with repeated cross sections of data. And given that I have sample weights, where/how could I use them to get population figures from these sample numbers?

Many thanks for your help in advance!

Best regards
Ola


Code:
//Generate variable for total number of mothers
gen mother=1 if sex==2 & nchild>0
replace mother=0 if (mother>= .)
label var mother "Mother"
egen totalmothers=total(mother), by(statefip year)
label var totalmothers "Total mothers"

// Generate variable for number of teenage mothers (contemporaneous)
gen teenagemother=1 if nchild>0 & age>13 & age<20
replace teenagemother = 0 if (teenagemother >= .)
label var teenagemother "Teenage mother"

// Generate share of new teenage mothers
sort statefip year
egen totalteenagemothers=total(teenagemother), by(statefip year)
label var totalteenagemothers "Total teenage mothers"

/// Estimate prevalence of teenage mothers (per 100 population)
gen shareofteenagemothers=(totalteenagemothers/totalmothers)*100
label var shareofteenagemothers "Share of teenage mothers"