Dear experts,
I kindly ask you to help on how I export couple of outputs from Stata. The first is, I want to export a matrix from decomposition analysis between time periods. Last time, I posted a similar post on how to export a newly generated variable. But, here, I would like to ask the same question but these variables need to be exported using matrix
The problem I faced is on the matrix (towards the end of the code).
My second question is related to exporting cross tabulation of many variables at once in one big table. That, is I want to do cross tabulations between all of my exposure variables with an outcome variable and exporting all of them once. I tried using tabout ( see below) but the code gives me weighted count only, not the number of observations in each cell of the cross tabulation.
The last variable, PNC_skiiled2, is outcome variable and the other are exposures. Do you help how I also or ,instead of weighted count, present number of observations for each cell in the cross tabulation in this code
or other similar code?
If I get an automatic export method, it would save me a lot of time and energy.
Thank you in advance.
I kindly ask you to help on how I export couple of outputs from Stata. The first is, I want to export a matrix from decomposition analysis between time periods. Last time, I posted a similar post on how to export a newly generated variable. But, here, I would like to ask the same question but these variables need to be exported using matrix
Code:
qui sum anc_quality_binary if survey==4 [aw=wt] sca m_y=r(mean) svy: qui glm anc_quality_binary $X if survey==4, family(binomial) link(logit) foreach x of varlist $X { sca b_`x'=_b[`x'] } foreach x of varlist $X { qui { conindex `x' if survey==4, rank(swpatt3gr) truezero svy gen CI16_`x' = r(CI) sum `x' if survey==4 [aw=wt] sca m_`x'=r(mean) gen elas16_`x' = (b_`x'*m_`x')/m_y sca con_`x' = 4*b_`x'*m_`x'*CI16_`x' sca prcnt_`x' = 100*con_`x'/EI16 gen CC`x' = elas16_`x'*(CI16_`x' - CI00_`x') + CI00_`x'*(elas16_`x' - elas00_`x') gen CE`x' = elas00_`x'*(CI16_`x' - CI00_`x') + CI16_`x'*(elas16_`x' - elas00_`x') gen cha_Ela`x' = elas16_`x' - elas00_`x' gen cha_C`x' = CI16_`x' - CI00_`x' } di "`xí elasticity 1:", elas16_`x' di "`xí elasticity 2:", elas00_`x' di "`xí concentration index 3:", CI16_`x' di "`xí concentration index 4:", CI00_`x' di "`xí contribution to change 5:", CC`x' di "`xí chnage in Ela 6:", cha_Ela`x' di "`xí chnage in CI 7:", cha_C`x' matrix qu_nm = nullmat(qu_nm)\ (elas16_`x', elas00_`x', CI16_`x', CI00_`x', CC`x', cha_Ela`x', cha_C`x') } matrix rownames qu_nm= $X matrix colnames qu_nm = "elasticity 1""elasticity 2""concentration index 3""concentration index 4""contribution to change 5""chnage in Ela 6""chnage in CI 7" matrix list qu_nm , format(%8.3f)
My second question is related to exporting cross tabulation of many variables at once in one big table. That, is I want to do cross tabulations between all of my exposure variables with an outcome variable and exporting all of them once. I tried using tabout ( see below) but the code gives me weighted count only, not the number of observations in each cell of the cross tabulation.
Code:
tabout at_birth_for_PNC region v106_new husband_edu_new v190 women_occupation husband_occupation religion_f_pnc religion_f media_new wantedness_child swpatt3gr swpsoc3gr swpdec3gr birthor PNC_skiiled2 using tablePNC2011Urban.xls if survey==4 & v025==2, cells(freq) format(0 1) clab(No. Col_% Cum_%) svy rep
The last variable, PNC_skiiled2, is outcome variable and the other are exposures. Do you help how I also or ,instead of weighted count, present number of observations for each cell in the cross tabulation in this code
or other similar code?
If I get an automatic export method, it would save me a lot of time and energy.
Thank you in advance.
Comment