I've recently started to work more with survey data, and discovered Stata's survey functions. However, I am having trouble with the svy:proportion method.
I have svyset my dataset and then, having collected my dependent and independent variables in local macros, I expected this following code to run:
Code:
svyset [pw=Weight],strata(Region) singleunit(certainty) local depvar [InEmp UnEmp] local indvars [ib1.age ib1.ethgrp ] svy: proportion `depvar' matrix result=r(table) local n=e(N) matrix `depvar'=J(1,9,.) matrix colnames `depvar'="Percentage" "SE" "Lower95%" "Upper95%" "Difference" "SE" "Pvalue" "stars" "Base" matrix `depvar'[1,1]=result[1,2]*100 matrix `depvar'[1,2]=result[2,2]*100 matrix `depvar'[1,3]=result[5,2]*100 matrix `depvar'[1,4]=result[6,2]*100 matrix `depvar'[1,9]=`n'
I looked at the manual, and there is probably a very simple fix, but I can't see it right now. Any ideas?
Thank you in advance
0 Response to Working with survey data: using weights in svy: proportion
Post a Comment