Announcement

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

  • Tabstat to Excel

    Good day all,

    I have a table of summary statistics which I would like exported in the exact same form as shown below but I can't seem to manage with putexcel.

    Does anyone know how I can best do this?

    My table is created by
    Code:
    tabstat at act che lct dlc dp sale rect ppegt ni oancf xidoc, statistics(p25 mean p50 p75 sd) column(statistics)
    And it looks like this


  • #2
    I couldn't decipher your image and I don't ever feel the need to export results to Excel, so I don't know much about it.

    But I know that you could collapse the dataset to get the same results and then export it.

    Comment


    • #3
      Would you be able to provide a code example how I would use the collapse and export commands in my code? I'm not following.

      Comment


      • #4
        I could in turn suggest that you provide a data example, as we always ask (FAQ Advice #12).

        Code:
        sysuse auto, clear
        collapse (mean) mean=mpg (sd) sd=mpg, by(foreign)
        list 
        
             +------------------------------+
             |  foreign      mean        sd |
             |------------------------------|
          1. | Domestic   19.8269    4.7433 |
          2. |  Foreign   24.7727   6.61119 |
             +------------------------------+
        
        export excel using whatever.xls
        You have more measures and more variables to summarize, but the principle is the same.

        Comment


        • #5
          There is a way to do this using putexcel. You can store a matrix of the tabstat table using the save option. Have a look at the example below.
          Code:
          sysuse auto, clear
          
          tabstat price mpg rep78 headroom trunk weight, statistics(p25 mean p50 p75 sd) columns(statistics) save
          mat T = r(StatTotal)' // the prime is for transposing the matrix
          
          putexcel set "myresults.xlsx" // remember to specify the full path
          putexcel A1 = matrix(T), names

          Comment


          • #6
            Good day users i am having the same problem i have tried to use putexcel but it doesnt seem to work. Is there a command that i can use to export these results to excel. Currently i am using the "copy table"option which is time consuming since i have got multiple tables: Please see an example of one of my tables
            Facility 30-34 35-39 40-44 45-49 50+ Total
            GP ADELAIDE TAMBO C.. 0 0 0 0 4 4
            GP ATTERIDGEVILLE C.. 0 1 0 0 2 4
            GP BOEKENHOUT CLINIC 1 0 0 1 4 8
            GP BOIKHUTSONG CLINIC 1 1 0 0 5 8
            GP BOPHELONG CLINIC.. 0 0 1 0 1 3
            GP BRONKHORSTSPRUIT.. 0 1 0 1 5 7

            Last edited by Nkululeko Mngomezulu; 02 Apr 2019, 03:45.

            Comment

            Working...
            X