Dear all,
I am wondering where the unbalanced parentheses are in my line of commands below. The error is "parentheses do not balance". I have really tried redoing the codes but I am not still sure what's going on.
I am wondering where the unbalanced parentheses are in my line of commands below. The error is "parentheses do not balance". I have really tried redoing the codes but I am not still sure what's going on.
Code:
use "Output/Reshaped1.dta", clear local vars v106 v190 v151 v3a13 v249 v217 local labels HighestEducLevel Wealth Sex_HouseholdHead UsedEmergContraPast12Months AgeMenarche knowledgeOvulCycle local titles "Teenage Births by Highest Education Level" /// "Teenage Births by Wealth quintiles" /// "Teenage Births by Sex of Household Head" /// "Teenage Births by Use of Contraceptives" /// "Teenage Births by Age at Menarche" /// "Teenage Births by Knowledge of Ovulatory Cycle" local outputs "Bar_BirthsbyEduc.pdf" "Bar_BirthsbyWealth.pdf" "Bar_BirthsbySexHHhead.pdf" /// "Bar_BirthsbyContraceptiveUsage.pdf" "Bar_BirthsbyAgeMenarche.pdf" "Bar_BirthsbyKnowOvulCycle.pdf" local ylabels "0(100)1000" "0(100)900" "0(100)1500" "0(100)1100" "0(25)275" "0(50)400" local i = 1 foreach var of local vars { use "Output/Reshaped1.dta", clear * Collapse the dataset by summing up the count of teenage births by outcome_year and the variable of interest collapse (sum) year_, by(outcome_year `var') rename year_ TeenageBirths local label : word `i' of `labels' rename `var' `label' * Apply any special conditions if "`var'" == "v249" { keep if `label' >= 9 & `label' <= 19 } * Generate the graph local title : word `i' of `titles' local output : word `i' of `outputs' local ylabel : word `i' of `ylabels' graph bar (sum) TeenageBirths, over(`label') /// plotregion(style(none)) /// ysize(15) /// title("`title'", size(medium)) /// ytitle("Teenage births") /// ylabel(`ylabel') /// note("Note: Data restriction: 2017 to 2021") graph export "Output/`output'", replace local i = `i' + 1 }
Comment