Announcement

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

  • putexcel query

    how can I put more than one result in a single excel cell? for example, say I want to grab both the mean and the standard deviation from a -summarize- result as follows: mean (sd); I know how to grab the mean and sd - that is not the issue; the issue is getting both in one cell with the parentheses; use of the standard auto.dta file is fine as in
    Code:
    sysuse auto, clear
    su gear

  • #2
    Seems to me the approach needed is to create a string with what you want in the cell. Or am I misunderstanding what you want? Certainly you cannot have two numbers in one Excel cell, any more than you can have two values in one observation of a Stata variable.
    Code:
    . sysuse auto, clear
    (1978 Automobile Data)
    
    . summarize gear_ratio
    
        Variable |        Obs        Mean    Std. Dev.       Min        Max
    -------------+---------------------------------------------------------
      gear_ratio |         74    3.014865    .4562871       2.19       3.89
    
    . local result = string(r(mean),"%9.2f") + "  (" + trim(string(r(sd),"%9.3f") + ")")
    
    . macro list _result
    _result:        3.01 (0.456)
    
    . putexcel set "~/Downloads/sl.xlsx", replace
    Note: file will be replaced when the first putexcel command is issued
    
    . putexcel B2 = "`result'"
    file /Users/lisowskiw/Downloads/sl.xlsx saved
    
    . putexcel save
    
    .
    Click image for larger version

Name:	sl.png
Views:	1
Size:	30.6 KB
ID:	1538357

    Comment


    • #3
      thank you

      Comment

      Working...
      X