Announcement

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

  • Accessing estadd ysumm estimates from .ster file and exporting to excel

    Hello! I am attempting to access the regression estimates I have stored in a stata .ster file and export these estimates into excel using matrices (saving estimates as local macros and exporting with matrix = `macro' and putexcel).

    I ran regressions of the form:

    eststo `outcome'_8: quietly regress `outcome' nurse lawyer doc `controls'

    quietly estadd local fake "No", replace
    quietly estadd local fake2 "No", replace
    estadd ysumm, replace


    Previously I have simply output these results using esttab (esttab `outcome'_8 using "$temp/fake_`outcome'.tex", replace label s(fake fake2 ymean)). And the mean of the dependent var (saved using estadd ysumm, replace) gets output successfully (along with the other scalars which aren't of interest to me right now). However now that I am saving estimates to a .ster file, I have not been able to figure out how view or access the saved estimates of ysumm / ymean (the mean of the dependent var) I saved.

    I have tried using "ereturn list", and I see the following once I open the .ster file (and confirm that my regression results are successfully stored in there) and type ereturn list:

    . ereturn list

    scalars:

    e(N_clust) = 1668466

    e(N) = 5154055

    e(df_m) = 828

    e(df_r) = 1668465

    e(F) = 826.8644975199667

    e(r2) = .2104039008850213

    e(rmse) = .3394628972403003

    e(mss) = 158238.6647468456

    e(rss) = 593832.3001033629

    e(r2_a) = .2102770317024807

    e(ll) = -1744480.008596252

    e(ll_0) = -2353260.830340802

    e(rank) = 829




    macros:

    e(cmd) : "regress"

    e(estimates_title) : "est1"

    e(vcetype) : "Robust"

    e(estat_cmd) : "regress_estat"

    e(model) : "ols"

    e(predict) : "regres_p"

    e(properties) : "b V"

    e(depvar) : "has_drug_inf"

    e(vce) : "cluster"

    e(marginsok) : "XB default"

    e(title) : "Linear regression"

    e(cmdline) : "regress has_fake_outcome nurse lawyer doc_f.."




    matrices:

    e(b) : 1 x 837

    e(V) : 837 x 837

    e(V_modelbased) : 837 x 837


    Can someone please let me know how I can access the ysumm (or ymean) that I saved using "estadd ysumm" and save this as a local macro or variable so that I can export it to excel along with the other regression estimates?

    Thank you!
    Last edited by Simone Matecna; 01 Apr 2022, 16:23. Reason: .ster files exporting excel

  • #2
    estout is from SSC (FAQ Advice #12). You do not show the -estimates save- command that creates the .ster files. If you save the results prior to adding the ysumm results, then they will not be included. Also, note that you increase your chances of getting helpful replies by presenting a reproducible example (see referenced FAQ Advice).

    Code:
    quietly regress outcome_8 nurse lawyer doc `controls'
    quietly estadd local fake "No", replace
    quietly estadd local fake2 "No", replace
    estadd ysumm, replace
    estimates save outcome_8
    clear
    estmates clear
    estimates use outcome_8
    esttab ., replace label s(fake fake2 ymean)
    Last edited by Andrew Musau; 02 Apr 2022, 15:27.

    Comment

    Working...
    X