Hi all,
I am trying to export the mean and CV of a list of variables. Below is my code which successfully exports the list of variables and their means overall and then disaggregated by job type. I want to add another column to the excel that shows the CV and maybe some other summary stats but can't figure it out. I found code using svy: tab varname which works for dummy variables but not for continuous variables.
Thanks in advance for any support you can give me.
I am trying to export the mean and CV of a list of variables. Below is my code which successfully exports the list of variables and their means overall and then disaggregated by job type. I want to add another column to the excel that shows the CV and maybe some other summary stats but can't figure it out. I found code using svy: tab varname which works for dummy variables but not for continuous variables.
Code:
svyset upm [pweight = fac_tri], strata(est_d_tri) vce(linearized) singleunit(scaled)
gl vars varlist // about 30 more vars
putexcel set "Output\Indicators.xlsx", sheet("Overall") replace
putexcel A1 = "Var"
putexcel B1 = "Mean"
*Run through each variable
loc row = 2
foreach var of varlist $vars {
svy: mean `var'
estat cv
matrix a = e(b)
matrix rownames a = "`var'"
putexcel A`row'= matrix(a), rownames nformat(number_d2)
loc row = `row' + 1
}
putexcel set "Output\Indicators.xlsx", sheet("Activity", replace) modify
putexcel A1 = "Var" B1 = "Agro" C1 = "Educativa u hospital" D1 = "Publica o una sin fines" ///
E1 = "Privado" F1 = "No se puede peterminar"
*Run through each variable by job type
loc row = 2
foreach var of varlist $vars {
svy: mean `var', over(p4b)
matrix a = e(b)
matrix rownames a = "`var'"
putexcel A`row'= matrix(a), rownames nformat(number_d2)
loc row = `row' + 1
}
