Announcement

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

  • Issues using esttab

    Hi All,
    I'm now trying to use esttab for generating the table: Could you please explain why I don't get the table output like the below

    I run the blew code first !
    code:
    estpost tabstat new_cases new_deaths new_tests new_vaccinations, c(stat) stat(sum mean sd min max n)

    And then,
    code:
    esttab, ///
    cells("sum(fmt(%13.0fc)) mean(fmt(%13.2fc)) sd(fmt(%13.2fc)) min max count") nonumber ///
    nomtitle nonote noobs label collabels("Sum" "Mean" "SD" "Min" "Max" "N")

    but

    the number is only present in N column, and the other columns are blank. Please suggest me! please see the attached file.


    Here is sample data :

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long new_cases int new_deaths long(new_tests new_vaccinations)
      5  . . .
      0  . . .
      0  . . .
      0  . . .
      0  . . .
      0  . . .
      0  . . .
      0  . . .
      0  . . .
      0  . . .
      0  . . .
      0  . . .
      3  . . .
      0  . . .
      0  . . .
      0  . . .
      3  . . .
      0  . . .
      0  . . .
      3  . . .
      6  . . .
      5  . . .
      1  . . .
      0  . . .
      0  . . .
      .  . . .
      0  . . .
     10  . . .
      6  1 . .
      2  0 . .
     32  0 . .
      6  1 . .
     11  0 . .
     15  0 . .
      8  2 . .
      0  0 . .
     52  0 . .
     26  0 . .
     43  0 . .
     34  1 . .
      1  0 . .
     29  2 . .
     38  0 . .
     30  4 . .
     56  3 . .
     21  1 . .
     77  0 . .
      0  0 . .
     34  3 . .
     52  1 . .
     58  3 . .
    105  3 . .
     24  4 . .
     51  1 . .
     63  0 . .
     25  0 . .
     63  3 . .
     30  3 . .
     66  0 . .
     84  4 . .
     50  0 . .
    104  3 . .
    133  6 . .
     68  1 . .
    172 10 . .
    124  0 . .
      0  0 . .
    344  4 . .
    298  8 . .
      0  0 . .
      0  0 . .
      0  0 . .
    755 23 . .
    168  9 . .
    171  1 . .
      0  0 . .
    839 14 . .
    262  1 . .
    303  7 . .
      0  0 . .
    372  9 . .
    714 17 . .
    349 15 . .
    233  1 . .
    437  4 . .
    583  4 . .
    490 10 . .
    531  6 . .
    540 12 . .
    736 10 . .
    716  7 . .
    512  1 . .
    737  1 . .
    548  6 . .
    637  9 . .
    643 11 . .
    784  2 . .
    651  2 . .
    656 15 . .
    742  5 . .
    end
    ------------------ copy up to and including the previous line ------------------

    Listed 100 out of 110908 observations
    Use the count() option to list more

    .


    Attached Files
    Last edited by Thein Zaw; 17 Oct 2021, 05:18.

  • #2
    estout is from the Stata Journal/ SSC, as you are asked to explain (FAQ Advice #12). Look at the capitalization:

    Code:
    esttab, cells("sum(fmt(%13.0fc))
    should be

    Code:
    esttab, cells("Sum(fmt(%13.0fc))

    Comment


    • #3
      The code in post #1 is not the same as the code in the picture of the output.

      Here is sample code, using the latest version of the estout package available on SSC, that seems to do what you want.
      Code:
      . which estpost
      /Users/lisowskiw/Library/Application Support/Stata/ado/plus/e/estpost.ado
      *! version 1.2.1  19may2021  Ben Jann
      
      . which esttab
      /Users/lisowskiw/Library/Application Support/Stata/ado/plus/e/esttab.ado
      *! version 2.1.0  19may2021  Ben Jann
      *! wrapper for estout
      
      . sysuse auto, clear
      (1978 automobile data)
      
      . estpost tabstat price weight, c(stat) stat(sum mean sd min max count)
      
      Summary statistics: sum mean sd min max count
           for variables: price weight
      
                   |    e(sum)    e(mean)      e(sd)     e(min)     e(max)   e(count)
      -------------+------------------------------------------------------------------
             price |    456229   6165.257   2949.496       3291      15906         74
            weight |    223440   3019.459   777.1936       1760       4840         74
      
      . esttab , cells("sum(fmt(%13.0fc)) mean(fmt(%13.2fc)) sd(fmt(%13.2fc)) min max count") ///
      > nonumber nomtitle nonote noobs label collabels("Sum" "Mean" "SD" "Min" "Max" "N")
      
      --------------------------------------------------------------------------------------------------
                                    Sum         Mean           SD          Min          Max            N
      --------------------------------------------------------------------------------------------------
      Price                     456,229     6,165.26     2,949.50        3,291       15,906           74
      Weight (lbs.)             223,440     3,019.46       777.19        1,760        4,840           74
      --------------------------------------------------------------------------------------------------
      
      .
      I particularly notice that while my output shows in the output of estpost
      Code:
      Summary statistics: sum mean sd min max count
      your picture shows
      Code:
      Summary statistics: Sum Mean SD Min Max count
      which makes me wonder if your version of estout is up to date.

      Added in edit: crossed with post #2, which makes essentially the same point: the cells named in esttab need to agree with the statistics described by estpost.
      Last edited by William Lisowski; 17 Oct 2021, 07:50.

      Comment

      Working...
      X