I've a question about writing output from the svy: logit function to matrices. So that later I can more easily export them to excel, using the putexcel function.
I've written the following code, where my independent variables are categorical variables:
Code:
// setting up macros local basecat =substr("`indvars'",3,1) levelsof Year, local(Yearlevels) local depvar X Y local invars a b foreach yr of local Yearlevels{ foreach invar of local invars{ foreach dpvar of local depvar{ svy: proportion `dpvar' if Year==`yr', over(`invar') matrix result= r(table) local cat=e(N_over) matrix p`dpvar'=result[1,`cat'+1..`cat'*2]*100 matrix se`dpvar'=result[2,`cat'+1..`cat'*2]*100 matrix dfs=J(`cat',2,.) // forvalues j = 1/`cat' { // local dif `j'=p[1,`j']-p[1,`basecat'] // local sedif`j'=sqrt(se[1,`j']*se[1,`j']+se[1,`basecat']*se[1,`basecat']) // // matrix dfs[`j',1]=`dif`j'' // matrix dfs[`j',2]=`sedif`j'' // // matrix dfs[`basecat',1]=. // // matrix dfs[`basecat',2]=. // } matrix ll=result[5,`cat'+1..`cat'*2]*100 matrix ul=result[6,`cat'+1..`cat'*2]*100 } } }
Can anyone help me out here?
Thank you.
0 Response to Putting output from svy: logit into matrices
Post a Comment