Announcement

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

  • Formatting decimal position in esttab command

    . esttab, cell((mean(label(Mean) fmt(%9.2f)) median(label(Median)) sd(label(Std Deviation) fmt(%9.2f)) min(label(Min) fmt(%9.2f)) max(label(Max) fmt(%9.2f)))
    > )

    . esttab using C:\ABC\summary.rtf, modelwidth(10 20) cell((mean(label(Mean)) ///
    > sd(par label(Standard Deviation)) min(label(Min)) max(label(Max)))) ///
    > label nomtitle nonumber replace ///
    > title("Table #: Descriptive Statistics")

    Table #: Descriptive Statistics
    Mean Standard Deviation Min Max
    Access -3.71e-09 .4985824 -.975475 5.30083
    Corruption 7.40e-09 .5319847 -1.272017 2.087455
    Gender 1.000326 1.000027 0 2
    Media -6.35e-10 .6984663 -1.013079 4.516181
    Democracy 2.419828 1.306305 0 9
    Speech 4.24e-09 .6865565 -2.168589 5.111472
    Age 37.36189 22.69637 18 999
    University .2978585 1.514686 0 8
    Observations 18398
    I am using the above esttab command coding to maintain the hundredth position to the right of the decimal point with no success (eg: .12). Please see my resulting output. What am I missing?

    Thank you.

    Yarh Komolo

  • #2
    estout is from SSC (FAQ Advice #12). You should show your full commands. This works for me, with the last line being identical to your command line, save "median" is replaced with "p50".

    Code:
    sysuse auto, clear
    estpost sum mpg weight displacement , d
    esttab, cell((mean(label(Mean) fmt(%9.2f)) p50(label(Median)) sd(label(Std Deviation) fmt(%9.2f)) min(label(Min) fmt(%9.2f)) max(label(Max) fmt(%9.2f))))
    Res.:

    Code:
    . esttab, cell((mean(label(Mean) fmt(%9.2f)) p50(label(Median)) sd(label(Std Deviation) fmt(%9.2f)) min(label(Min) fmt(%9.2f)) max(label(
    > Max) fmt(%9.2f))))
    
    -----------------------------------------------------------------------------
                          (1)                                                    
                                                                                
                         Mean       Median Std Deviat~n          Min          Max
    -----------------------------------------------------------------------------
    mpg                 21.30        20.00         5.79        12.00        41.00
    weight            3019.46      3190.00       777.19      1760.00      4840.00
    displacement       197.30       196.00        91.84        79.00       425.00
    -----------------------------------------------------------------------------
    N                      74                                                    
    -----------------------------------------------------------------------------

    If the above fails for you, update estout.

    Code:
    ssc install estout, replace

    Comment


    • #3
      Thanks, Andrew.

      I had very similar coding as you suggested (which did not work) before my forum inquiry. I shall revisit the issue towards the latter stage of my project.

      Yarh

      Comment


      • #4
        Hey, Andrew.

        I just stumbled onto the solution to my formatting issue. What I needed all along was to include the formatting option for each item in the “esttab using…” command line. See the following:

        . esttab using C:\ABC\summary.rtf, modelwidth(10 20) cell((mean(label(Mean) fmt(%9.2f)) ///
        > sd(par label(Standard Deviation) fmt(%9.2f)) min(label(Min) fmt(%9.2f)) max(label(Max) fmt(%9.2f)))) ///
        > label nomtitle nonumber replace ///
        > title("Table #: Descriptive Statistics ")

        Table #: Descriptive Statistics
        Mean Standard Deviation Min Max
        Access -0.00 0.50 -0.98 5.30
        Corruption 0.00 0.53 -1.27 2.09
        Gender 1.00 1.00 0.00 2.00
        Media -0.00 0.70 -1.01 4.52
        Democracy 2.42 1.31 0.00 9.00
        Speech 0.00 0.69 -2.17 5.11
        Age 37.36 22.70 18.00 999.00
        University 0.30 1.51 0.00 8.00
        Observations 18398

        Yarh

        Comment

        Working...
        X