This is possible with flexmat. I encourage you to invest an hour or less on flexmat, and shall have the freedom to make sophisticated tables. Here is a starting blog post https://asdocx.com/flexmat-create-flexible-tables-in-stata-mata/. Let me show an example for creating your desired table.
sysuse auto , clear
loc NextRow 2
flexmat reset
flexmat addrow , data(Variable , Obs , Mean , Std. dev. , Min , Max) row(1)
foreach var in price mpg trunk {
sum `var' if `var' != 999
flexmat addrow , data(`r(N)',`r(mean)',`r(sd)', `r(min)',`r(max)' ) row(`NextRow') dec(3)
loc ++NextRow
}
asdocx export
Table: Results
Variable |
Obs |
Mean |
Std. dev. |
Min |
Max |
price |
74 |
6165.257 |
2949.496 |
3291 |
15906 |
mpg |
74 |
21.297 |
5.786 |
12 |
41 |
trunk |
74 |
13.757 |
4.277 |
5 |
23 |
Notes: |