Announcement

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

  • How to format different regressors using main(name [fmt])? (Stata Esttab)

    When we are creating tables in STATA using esttab,

    1. According to this document http://repec.org/bocode/e/estout/hlp_estout.html, we can add different formats to different regressors in a model. So for example, b(fmt(2 3 3)) will output the first regressor's point estimate in 2 decimal format and the second and third regressor's point estimates in 3 decimal formats.

    2. The document also mentions the using of "main(name) to display a different statistic than the default point estimates, and we can even add formatting to this user-chosen statistic. So for example main(mean 2) will put the mean of the regressor in a 2 decimal format.

    My question is, therefore, how to combine the two techniques mentioned above and format a user-chosen static differently for different regressors? So ideally, I am thinking about something like

    main(mean 2 3 3), which will out the mean for the first regressor in 2 decimal format, and mean for the second and third regressor in 3 decimal format. This apparently does not work, as the output is a span of multiple created tables that couldn't even fit in a single page.

  • #2
    estout is from SSC (FAQ Advice #12). Also, note the spelling of Stata - https://www.statalist.org/forums/help#spelling. Welcome to Statalist. The feature that you refer to requires the -cells()- option. Consider:

    Code:
    sysuse auto, clear
    estpost summarize price weight rep78 mpg if !foreign
    est sto domestic
    estpost summarize price weight rep78 mpg if foreign
    est sto foreign
    esttab domestic foreign, cells(mean(fmt(2 3 4 5)))
    Res.:

    Code:
    . esttab domestic foreign, cells(mean(fmt(2 3 4 5)))
    
    --------------------------------------
                          (1)          (2)
                                          
                         mean         mean
    --------------------------------------
    price             6072.42      6384.68
    weight           3317.115     2315.909
    rep78              3.0208       4.2857
    mpg              19.82692     24.77273
    --------------------------------------
    N                      52           22
    --------------------------------------

    Comment


    • #3
      Originally posted by Andrew Musau View Post
      estout is from SSC (FAQ Advice #12). Also, note the spelling of Stata - https://www.statalist.org/forums/help#spelling. Welcome to Statalist. The feature that you refer to requires the -cells()- option. Consider:

      Code:
      sysuse auto, clear
      estpost summarize price weight rep78 mpg if !foreign
      est sto domestic
      estpost summarize price weight rep78 mpg if foreign
      est sto foreign
      esttab domestic foreign, cells(mean(fmt(2 3 4 5)))
      Res.:

      Code:
      . esttab domestic foreign, cells(mean(fmt(2 3 4 5)))
      
      --------------------------------------
      (1) (2)
      
      mean mean
      --------------------------------------
      price 6072.42 6384.68
      weight 3317.115 2315.909
      rep78 3.0208 4.2857
      mpg 19.82692 24.77273
      --------------------------------------
      N 52 22
      --------------------------------------
      Thank you Andrew, this worked like a charm! And thanks for reminding me, I will try to be careful with my spelling.

      Comment

      Working...
      X