Announcement

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

  • Summary Statistics - N not displaying

    Dear All,

    I hope you're doing great! While doing some initial summary stats of a database. I tried running the following code

    Code:
    global outcomes preferred1 preferred2 leader_self1 leader_self2 leader_others1 leader_others2 leadership_nominations1 leadership_nominations2 leadership_nominations
    
    foreach y of global outcomes {
        estpost tabstat `y' ,by(session) statistics(n min p1 p5 p25 p50 p75 p95 p99 max mean sd)
        esttab using "$tables/summary_`y'.tex", tex replace cells("N min p1 p5 p25 p50 p75 p95 p99 max mean sd") mtitle (`y')  nonumber
        eststo clear
            
    }
    However, I cannot see the number of observations by session correctly. The output looks something like this:
    Click image for larger version

Name:	Captural.PNG
Views:	1
Size:	28.5 KB
ID:	1757581


    I'd like to see the total number of obs, and # of obs per session, but I'm not being able to. Any help is highly appreciated!


  • #2
    estout is from SSC (FAQ Advice #12). You need to examine the matrix that the command creates. Below, the statistic is named "count", so you'd substitute "N" for "count".

    Code:
    sysuse auto, clear
    eststo: estpost tabstat mpg, by(foreign) stats(n mean sd)
    Res.:

    Code:
    sysuse auto, clear
    (1978 automobile data)
    
    . eststo: estpost tabstat mpg, by(foreign) stats(n mean sd)
    
    Summary statistics: count mean sd
         for variables: mpg
      by categories of: foreign
    
         foreign |  e(count)    e(mean)      e(sd) 
    -------------+---------------------------------
        Domestic |        52   19.82692   4.743297 
         Foreign |        22   24.77273   6.611187 
    -------------+---------------------------------
           Total |        74    21.2973   5.785503 
    (est1 stored)

    Comment


    • #3
      thank you for your help! sadly replacing the code by count doesn't change the output. Even with the option "noobs" there seems to be no change. I still cannot see the number of observations by session

      Comment


      • #4
        Show us the exact Stata output from running the commands.

        Comment


        • #5
          Sure! Thank you!

          Code:
          global outcomes preferred1 preferred2 leader_self1 leader_self2 leader_others1 leader_others2 leadership_nominations1 leadership_nominations2 leadership_nominations
          
          foreach y of global outcomes {
              estpost tabstat `y' ,by(session) statistics(count min p1 p5 p25 p50 p75 p95 p99 max mean sd)
              * Combine and export the summary statistics
              esttab using "$tables/summary_`y'.tex", tex replace cells("N min p1 p5 p25 p50 p75 p95 p99 max mean sd") mtitle (`y')  nonumber 
              eststo clear
                  
          }
          Click image for larger version

Name:	Captural.PNG
Views:	1
Size:	27.7 KB
ID:	1757631

          Comment


          • #6
            I do not mean the table. I mean copy all the output from the Command Window as I have done in #2. I want to see the matrix column names.

            Comment


            • #7
              Code:
              Summary statistics: count min p1 p5 p25 p50 p75 p95 p99 max mean sd
                   for variables: leadership_nominations
                by categories of: session
              
                   session |  e(count)     e(min)      e(p1)      e(p5)     e(p25)     e(p50)     e(p75)     e(p95)     e(p99) 
              -------------+---------------------------------------------------------------------------------------------------
                  Macro_ME |        13          0          0          0          0          1          1          3          3 
                  Macro_MH |        22          0          0          0          1          2          3          3          3 
                  Macro_OB |        30          0          0          0          1          2          2          3          3 
                  Micro_DB |        54          0          0          0          1          2          3          3          3 
                  Micro_JC |        28          0          0          0          1          2          2          3          3 
                      PP-2 |        35          0          0          0          1          2          2          3          3 
                      PP-1 |        52          0          0          0          1          2          2          3          3 
              -------------+---------------------------------------------------------------------------------------------------
                     Total |       234          0          0          0          1          2          2          3          3 
              
                   session |    e(max)    e(mean)      e(sd) 
              -------------+---------------------------------
                  Macro_ME |         3   .9230769   .8623165 
                  Macro_MH |         3   1.772727   1.066004 
                  Macro_OB |         3   1.733333    .868345 
                  Micro_DB |         3   1.925926   .9080739 
                  Micro_JC |         3   1.857143   .8482787 
                      PP-2 |         3   1.514286   .9194445 
                      PP-1 |         3   1.826923   .8794195 
              -------------+---------------------------------
                     Total |         3   1.739316   .9243912

              Comment


              • #8
                The statistic is named "count". If #5 was your modification to #1, then you misunderstood my advice in #2.

                Code:
                global outcomes preferred1 preferred2 leader_self1 leader_self2 leader_others1 leader_others2 leadership_nominations1 leadership_nominations2 leadership_nominations
                foreach y of global outcomes{
                    estpost tabstat `y' ,by(session) statistics(n min p1 p5 p25 p50 p75 p95 p99 max mean sd)
                    * Combine and export the summary statistics
                    esttab using "$tables/summary_`y'.tex", tex replace cells("count(label(N)) min p1 p5 p25 p50 p75 p95 p99 max mean sd") mtitle (`y') nonumber
                    eststo clear
                }

                Comment


                • #9
                  It worked!! Thank you so so much!

                  Comment

                  Working...
                  X