Announcement

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

  • putexcel, tabout or esttab?

    Dear all,

    I use Stata13 and I'm having some challenges exporting outputs to both Excel and Word.

    Though, I've exported tables using this command:
    estpost sum gini crime gdppc gdpgr dcredit
    esttab using "C:\Users\ng\Desktop\Thesis\SumStat.csv", cells("mean(fmt(2)) sd(fmt(2)) min(fmt(1)) max(fmt(1))") nomtitle nonumber replace

    But that doesn't seem to work for my next task. I became stuck trying to the 3 separate tables below to excel. I want all of them to be in 1 workbook so that I can further modify them into 1 table....that is if Stata cannot do that for me. But I've tried all the codes that I know to export ....all to no avail.....I've also tried 'putexcel'....but honestly I couldn't find my way around the click option neither do I know the exact codes to use. I've also gone through the online videos and read the 'pdfs'....still I can't export.

    Here are the tables:

    sum gini if year>=2000 & year<2004

    Variable | Obs Mean Std. Dev. Min Max
    -------------+--------------------------------------------------------
    gini | 548 .4015916 .1035351 .1537 .7526

    . sum gini if year>=2004 & year<2008

    Variable | Obs Mean Std. Dev. Min Max
    -------------+--------------------------------------------------------
    gini | 548 .3947124 .0989441 .1697 .674

    . sum gini if year>=2008

    Variable | Obs Mean Std. Dev. Min Max
    -------------+--------------------------------------------------------
    gini | 685 .3891018 .092145 .225 .6576999

    I'll appreciate every urgent assistance.
    Thanks.
    Ngzi

  • #2
    check out Stata's blog post on -putexcel-.

    Comment


    • #3
      ....thanks Mitch, but I've been on the blog for the past hour trying to construct this code. But I'm still struggling....here's the 'return' list for one of my summary statistics:

      return list

      scalars:
      r(N) = 548
      r(sum_w) = 548
      r(mean) = .4015916060302814
      r(Var) = .0107195167811974
      r(sd) = .1035350992716838
      r(min) = .1536999940872192
      r(max) = .7526000142097473
      r(sum) = 220.0722001045942

      matrices:
      r(C) : 15 x 15

      this is the code I constructed:

      putexcel A1 = ("Gini 4-year averages") B1 = ("2000-2003") ///
      A2 = ("# of obs") B2 = (r(N)) A3 = ("Mean") B3 = (r(mean))///
      B4 = (r(sd)) A5 = (r(min)) A6 = (r(max)) ///
      using C:\Users\ng\Desktop\Thesis\Gini.xlsx, sheet("Gini")replace

      ...and here's the error msg:
      no Excel file specified
      r(198);

      I've wasted almost 1hr on this thing....It's so frustrating when you not getting Stata.....kindly assist.

      Thanks.
      Ngozi





      Comment


      • #4
        Make sure there is at least one space before each /// (there isn't one on the A2 = line). Also maybe before the last replace. Stata often gets really fussy about missing or extraneous spaces, and it can be especially problematic on a multiline command since the problem isn't so obvious.
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        Stata Version: 17.0 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://www3.nd.edu/~rwilliam

        Comment


        • #5
          I got the same error you did when I copied your code. The error went away when I added the space before the /// on the A2 line, e.g.

          Code:
          webuse nhanes2f, clear
          sum weight
          putexcel A1 = ("Gini 4-year averages") B1 = ("2000-2003") ///
          A2 = ("# of obs") B2 = (r(N)) A3 = ("Mean") B3 = (r(mean)) ///
          B4 = (r(sd)) A5 = (r(min)) A6 = (r(max)) ///
          using temp, sheet("Gini")replace
          -------------------------------------------
          Richard Williams, Notre Dame Dept of Sociology
          Stata Version: 17.0 MP (2 processor)

          EMAIL: [email protected]
          WWW: https://www3.nd.edu/~rwilliam

          Comment


          • #6
            ....oh Richard....thanks you!!!....you've saved my life again....sometimes 'thank you' isn't enough to convey my gratitude. I felt so frustrated, spent over 1 hour just trying to figure out what was wrong with my code as I tried every step using Mitch's blog. All went well until I got stuck on the error msg.....and it was just about a 'space'???......aw!

            thank you Mitch, you blog is really educative!....please post more tutorials......indebted to you all!

            Ngozi

            Comment


            • #7
              the blog post i referred to here is not mine but of Kevin Crow of Stata over at The Stata Blog

              Comment


              • #8
                Glad it helped. I got space related errors myself at least 2 or 3 times yesterday. They are frustrating because they tend to produce totally inexplicable error messages, such as you got. Hopefully you will be a shining example to others about the benefits of showing the actual code used. Often there is some sort of syntax error and there is no way for others to detect that without seeing the code.
                -------------------------------------------
                Richard Williams, Notre Dame Dept of Sociology
                Stata Version: 17.0 MP (2 processor)

                EMAIL: [email protected]
                WWW: https://www3.nd.edu/~rwilliam

                Comment

                Working...
                X