0
votes

I am trying to get a summary table in Stata using the community-contibuted command estout.

However, I want to specify the number of decimals displayed per variable as opposed to the default which is per summary statistic.

As you can see in my code below, I know how to control the decimals for a summary statistic as a whole (e.g. the mean is displayed with no decimals):

* Summary statistics

eststo clear
estpost tabstat length weight, stat(mean median sd min max n) columns(statistics)

esttab using summstat1.rtf, cells("mean(label(Mean) fmt(2)) p50(label(Median) 
fmt(0)) sd(label(ST. Dev) fmt(2)) min(label(Min) fmt(2)) max(label(Max) fmt(2)) 
count(label(N) fmt(0))") label title("Summary Statistics") nonumbers lines noobs replace

What I want specifically is the following:

  • the length variable to be of the format 175 (i.e. no decimals)
  • the weight variable to be formatted such as 60.545 (i.e. three decimals)

Of course, I could try to scale my variables by dividing or multiplying times a factor 10, but this is not my problem and it something not desirable.

1

1 Answers

2
votes

For each summary statistic within the cells() option you can specify multiple formats.

Consider the following simplified example for mean:

sysuse auto, clear
eststo clear

estpost tabstat mpg price length weight, stat(mean) columns(statistics)

esttab, cells("mean(label(Mean) fmt(0 3 5 1))") 
        label title("Summary Statistics") ///
        nonumbers lines noobs 

Summary Statistics
---------------------------------

                             Mean
---------------------------------
Mileage (mpg)                  21
Price                    6165.257
Length (in.)            187.93243
Weight (lbs.)              3019.5
---------------------------------