Announcement

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

  • Exporting ANOVA results to Excel

    Hey Stata gurus,

    I'm having some trouble exporting my anova results to Excel. Before you direct me to the estout/putexcel/whatever documentation, let me just say ahead of time that I'm clearly doing something wrong even with that documentation (maybe I'm even using the wrong command documentation? I've been trying so many things at this point that I feel like I'm going cross-eyed) so I do still need some help. I'd really, really appreciate whatever you can tell me! :-)

    OK so here's my issue. I'm running 560 different ANOVAs and need A) to control for multiple comparisons, which appears to be easier in Excel, and B) to copy everything out into Excel so I can keep track of it and place the results into tables to show my PIs. I've messed around with putexcel, which seemed to have the best result but definitely nowhere near what I need. Based on some other threads I read, here's the code that seemed to work the "best:"

    . anova lh_amygdala_vol ptsd##c.cortisol c.education smoking
    . return list

    scalars:
    r(level) = 95

    macros:
    r(label60) : "(base)"
    r(label58) : "(base)"
    r(label6) : "(base)"
    r(label4) : "(base)"
    r(label1) : "(base)"

    matrices:
    r(table) : 9 x 63

    . mat A = r(table)
    . mat list A

    A[9,63]
    0b. 1. 0b.ptsd# 1.ptsd# 0b. 1.
    ptsd ptsd cortisol co.cortisol c.cortisol education education
    b 0 76.147741 206.81803 0 52.195744 0 731.49168
    se . 165.57285 560.65822 . 636.66582 . 541.57591
    t . .45990476 .36888432 . .08198295 . 1.3506725
    pvalue . .64594277 .71249373 . .93471905 . .17789483
    ll . -249.78293 -896.83943 . -1201.0829 . -334.6022
    ul . 402.07841 1310.4755 . 1305.4744 . 1797.5856
    df 279 279 279 279 279 279 279
    crit 1.9685031 1.9685031 1.9685031 1.9685031 1.9685031 1.9685031 1.9685031
    eform 0 0 0 0 0 0 0

    (this is abbreviated since there are a ton)

    . putexcel A8 = ("P values") using "/Users/macuser/Desktop/matrix"

    file /Users/macuser/Desktop/matrix.xlsx saved

    . putexcel B8 = (A[4,2]) using "/Users/macuser/Desktop/matrix", replace

    file /Users/macuser/Desktop/matrix.xlsx saved

    When I look at matrix.xlsx, it looks like when I typed in my first putexcel command, it just saved "P values" to cell A8. When I typed in my second putexcel command, it overwrote the file and only put the first p-value from my anova into cell B8. The rest is blank.

    Obviously I'm doing something very, very wrong but I have no idea where I've gone wrong. No one I know uses Stata so I'm kind of at a loss here. Any ideas?

    Thanks so much!

    -Caitlin

  • #2
    To answer your immediate problem, in your putexcel B8 command you want the "modify" option, not the "replace" option.

    Comment


    • #3
      Thank you so much, William! I'll give that a try.

      Comment

      Working...
      X