Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Saving svy: tab results to Excel with putexcel

    Hi Statalisters,

    I’m trying to pull cross-tabulated percentages (estimated with svy: tab) out of Stata to send to an Excel spreadsheet using the putexcel comment. I would like to save the percentages (but not the row or column totals) from this 2 X 2 table:
    . svy: tab behavdiff_2017 allergtotal, percent col
    Number of strata = 52 Number of obs = 6,863
    Number of PSUs = 533 Population size = 57,434,656
    Design df = 481
    ---------------------------------------------
    behavdiff | Ordinal allerg
    _2017 | No aller 1 allerg 2-4 alle Total
    ----------+-----------------------------------
    0 | 81.76 71.09 67.69 78.47
    1 | 18.24 28.91 32.31 21.53
    Total | 100 100 100 100
    --------------------------------------------------
    Pearson:
    Uncorrected chi2(2) = 116.7373
    Design-based F(1.99, 957.39) = 42.4172 P = 0.0000
    Before I show you all the things that Stata has stored away after that procedure, here’s a few things I thought would give me what I need. “e(Prop)” was my first choice.
    . matrix list e(Prop)

    e(Prop)[2,3]
    p11 p12 p13
    y1 .58980719 .13189235 .06300774
    y1 .13157606 .05364627 .03007038
    But this is giving me the proportion of the sample that’s in each cell. They add up to 1.0:
    . display .58980719 + .13189235 + .06300774 + .13157606 + .05364627 + .03007038
    .99999999
    This next command gives me the same result in a different layout.
    . matrix list e(b)

    e(b)[1,6]
    p11 p12 p13 p21 p22 p23
    y1 .58980719 .13189235 .06300774 .13157606 .05364627 .03007038
    Here is the full list of stored results that I get if I type in ereturn list. If you think you see what I need in here, I’d be grateful:
    . ereturn list
    scalars:
    e(df_r) = 481
    e(N_strata_omit) = 0
    e(singleton) = 0
    e(census) = 0
    e(stages) = 1
    e(cun_Penl) = 116.7373167155248
    e(F_Penl) = 33.89446293443975
    e(df1_Penl) = 1.982098655460592
    e(df2_Penl) = 953.3894532765449
    e(p_Penl) = 7.70642289861e-15
    e(cun_Pear) = 116.7373167155248
    e(F_Pear) = 42.41724461321405
    e(df1_Pear) = 1.990417470536126
    e(df2_Pear) = 957.3908033278768
    e(N) = 6863
    e(N_strata) = 52
    e(N_psu) = 533
    e(N_pop) = 57434656
    e(rank) = 5
    e(cvgdeff) = .0950342588703039
    e(mgdeff) = 1.72207060695022
    e(total) = 57434656
    e(c) = 3
    e(r) = 2
    e(pun_LLW) = 4.05071499502e-18
    e(Fun_LLW) = 43.57501368434244
    e(p_LLW) = 4.40241181592e-18
    e(F_LLW) = 43.48442114030015
    e(cun_LLW) = 87.15002736868487
    e(p_Full) = 1.91899898534e-14
    e(df2_Full) = 481
    e(df1_Full) = 1.990300259344187
    e(F_Full) = 33.89446293443975
    e(cun_Full) = 116.7373167155248
    e(p_LR) = 1.79769848951e-17
    e(df2_LR) = 957.3908033278768
    e(df1_LR) = 1.990417470536126
    e(F_LR) = 40.32412490942171
    e(cun_LR) = 110.9768016228261
    e(p_LRnl) = 3.63594554175e-14
    e(df2_LRnl) = 953.3894532765449
    e(df1_LRnl) = 1.982098655460592
    e(F_LRnl) = 32.22190808406095
    e(cun_LRnl) = 110.9768016228261
    e(p_Pear) = 2.63994377543e-18

    macros:
    e(cmdline) : "svy : tab behavdiff_2017 allergtotal, percent col"
    e(cmd) : "tabulate"
    e(prefix) : "svy"
    e(cmdname) : "tabulate"
    e(marginsnotok) : "_ALL"
    e(estat_cmd) : "svy_estat"
    e(collab) : "label"
    e(colvlab) : "Ordinal allerg"
    e(colvar) : "allergtotal"
    e(rowvar) : "behavdiff_2017"
    e(setype) : "cell"
    e(vcetype) : "Linearized"
    e(vce) : "linearized"
    e(wtype) : "pweight"
    e(wvar) : "wtfa_sc"
    e(wexp) : "= wtfa_sc"
    e(singleunit) : "missing"
    e(su1) : "ppsu"
    e(strata1) : "pstrat"
    e(depvar) : "Mean"
    e(properties) : "b V"

    matrices:
    e(b) : 1 x 6
    e(V) : 6 x 6
    e(V_srs_col) : 3 x 3
    e(Deft_col) : 1 x 3
    e(Deff_col) : 1 x 3
    e(V_srs_row) : 2 x 2
    e(Deft_row) : 1 x 2
    e(Deff_row) : 1 x 2
    e(V_srs) : 6 x 6
    e(Deft) : 1 x 6
    e(Deff) : 1 x 6
    e(V_col) : 3 x 3
    e(V_row) : 2 x 2
    e(Col) : 1 x 3
    e(Row) : 1 x 2
    e(Prop) : 2 x 3
    e(Obs) : 2 x 3
    e(_N_strata_certain) : 1 x 1
    e(_N_strata_single) : 1 x 1
    e(_N_strata) : 1 x 1

    functions:
    e(sample)
    Is there any way to derive the estimates that I want from these stored results? Or should I just give up?

    Thank you,
    Kevin

  • #2
    It's been a day since I posted this, so I thought I'd give it a "bump" (as per the FAQ). Any advice on this please? I'd greatly appreciate it.

    Comment


    • #3
      See https://www.statalist.org/forums/for...abels-to-excel for one possible solution.

      Comment

      Working...
      X