Announcement

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

  • which option in esttab that display number of observation with comma?

    When running esttab to got the table of results, I faced the problem of displaying the number of observations.
    Click image for larger version

Name:	11.PNG
Views:	1
Size:	2.1 KB
ID:	1621752

    I am wondering is there any option of esttab that I can add to display N with comma. For example, 368,776 or 215,432

  • #2
    The trick is that esttab will take all the options of estout as well, and after digging through the output of help estout I found that the following changes the format on N.
    Code:
    . esttab, stats(N,fmt("%9.0fc"))
    
    ----------------------------
                          (1)   
                            y   
    ----------------------------
    x                   2.010***
                      (57.84)   
    
    _cons             0.00434   
                       (0.22)   
    ----------------------------
    N                  10,000   
    ----------------------------
    t statistics in parentheses
    * p<0.05, ** p<0.01, *** p<0.001

    Comment


    • #3
      Hi William Lisowski
      Thank you for your trick

      When my code is
      Code:
      esttab m1 m2 m3 m4 m5 using "myfile.csv",star(* 0.1 ** 0.05 *** 0.01) ar2
      The result is
      N 368776 215432 215432 215432 215432
      adj. R-sq 0.585 0.648 0.648 0.649 0.651
      However, when I adjust as you mentioned
      Code:
      esttab m1 m2 m3 m4 m5 using "myfile.csv", stats(N,fmt("%9.0fc")) star(* 0.1 ** 0.05 *** 0.01) ar2
      The result is
      N ="368 776" ="215 432" ="215 432" ="215 432" ="215 432"
      At that moment N is wrong and the adjusted R square disappears.

      Could you please let me know how to fix it properly then?

      Comment


      • #4
        estout is from SSC, as you are asked to explain (FAQ Advice #12). If you activate estout using estout options, you deactivate esttab and therefore cannot rely on its defaults. estout requires that you list all the statistics that you want to include within -stats()-. Otherwise, see https://www.statalist.org/forums/for...scalars-n-sfmt for an esttab workaround to the problem.

        Comment


        • #5
          As Andrew describes, you need to include the adjusted r2 in the stats option.
          Code:
          . esttab, stats(N r2_a,fmt(%9.0fc %9.3f))
          
          ----------------------------
                                (1)  
                                  y  
          ----------------------------
          x                   1.977***
                           (112.93)  
          
          _cons             0.00435  
                             (0.43)  
          ----------------------------
          N                  10,000  
          r2_a                0.560  
          ----------------------------
          t statistics in parentheses
          * p<0.05, ** p<0.01, *** p<0.001
          or adopt the workaround he presented in the linked post.

          As to the "result" you show, what you show is the result of reading the csv output of esttab into a program that does not correctly read the csv, perhaps because important options were omitted when the csv was read.
          Code:
          . esttab using myfile.csv, stats(N r2_a,fmt(%9.0fc %9.3f))
          (output written to myfile.csv)
          
          . type myfile.csv
          
          ="",="(1)"
          ="",="y"
          
          ="x",="1.977***"
          ="",="(112.93)"
          
          ="_cons",="0.00435"
          ="",="(0.43)"
          
          ="N",="10,000"
          ="r2_a",="0.560"
          
          ="t statistics in parentheses"
          ="* p<0.05, ** p<0.01, *** p<0.001"
          
          .
          It appears that the quotation marks that are meant to "hide" the commas within the values of N are being ignored, and the values of N are being separated into two values by the comma. To repeat, this is not a problem with esttab, it is a problem with the way you read the csv.

          Comment

          Working...
          X