Announcement

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

  • Exporting summary stats generated with bysort. Putexcel?

    Hi,
    I've been using "putexcel" to export summary statistics into Excel.
    Now I'd like to use it after a
    bysort var1: summ var2 [fw=fwt]

    i.e I'd like to export summary statistics for each sub-group of var1.

    Is there any way to do this? Since only the last result is recorded, how can I export ALL the summary stats for each category of var1 ?
    I'd really appreciate any help.

    Thank you!
    Rosa


  • #2
    Instead of -bysort var1: summ...- run
    Code:
    tabstat var2 [fw=fwt], by(var1) statistics( N mean sd min max) save
    The results will be in a series of matrices in r(), and you can apply -putexcel- to those.

    Comment


    • #3
      Thank you Clyde. That worked!!

      Comment


      • #4
        Do you know how to modify this code to save the results of a cross tabulation that can then be exported into Excel (i.e., bysort var1: tab var2 var3, col all) if var2 is a string variable?
        Last edited by Samira Soleimanpour; 13 Nov 2019, 09:16.

        Comment


        • #5
          -tab- has options -matcell()-, -matrow()-, and -matcol()- which will capture the cells of the table and the names or labels in the row and column headers. With -matrix rownames- and -matrix colnames- commands you can make your matrix look like a nicely labeled table. And then -putexcel- will send it to Excel. It makes no difference at all whether var2 is string or numeric for this.

          Comment


          • #6
            Originally posted by Clyde Schechter View Post
            Instead of -bysort var1: summ...- run
            Code:
            tabstat var2 [fw=fwt], by(var1) statistics( N mean sd min max) save
            The results will be in a series of matrices in r(), and you can apply -putexcel- to those.
            Bumping this very old thread, but what if we have categorical data and tabstat won't suffice?

            Comment


            • #7
              See #5 in this thread.

              Comment

              Working...
              X