Cross post at: https://stackoverflow.com/questions/...-summary-table


I am trying to get a summary table in Stata using the Estout package. However, I want to specify the number of decimals displayed per variable (NOT per summary statistic).

The following example is similar to my actual dataset:

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

What I want to do is specify the format per variable:
  • the 'length' variable has to be of the format 175 (no decimals)
  • the 'weight' variable has to be formatted such as 60.545
Of course, I could try to scale my variables by dividing or multiplying times a factor 10, but this is not my problem and also not desired. The problem in my 'real' dataset is that some variables are percentages, some variables are in integers which means that setting for example mean to a fixed 5 decimals, it look stupid for the integer variable.

Here an example. In reality, I use more variables. I split up the code to make it more readable.
Code:
* Summary statistics
Code:
eststo clear
Code:
estpost tabstat length weight, stat(mean median sd min max n) columns(statistics)
Code:
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
Short: I want to control the number of decimals per variable, not per statistic (using the estout package)