tabstat: compact tables of selected statistics
Choose the statistics that matter for several variables, then repeat the same summary within groups.
Independent software. Not affiliated with, sponsored by, or endorsed by StataCorp LLC.
Complete example
clear
import delimited "data/student_scores.csv"
tabstat math read write, statistics(count mean sd min max)
by race: tabstat math, statistics(count mean sd)
The first command compares three variables in one table. The second uses the supported by prefix to calculate the same math statistics separately for each race code.
Output from stats.camp
Variable | Count Mean Std. Dev. Min Max
-------------+------------------------------------------------------
math | 24 57.375 7.654567 43 72
read | 24 56.166667 6.349712 44 68
write | 23 57.652174 6.69877 46 70
race Variable Count Mean Std. Dev.
1 math 6 50.500000 6.534524
2 math 6 60.500000 5.128353
3 math 6 54.333333 5.391351
4 math 6 64.166667 6.047038
How to read the result
The writing count is 23 because one value is missing; its other statistics use the same 23 nonmissing values. Each race group contains six math observations, and the group means range from 50.50 to about 64.17.
Group labels in these synthetic data are codes, not meaningful real-world categories.
Common options and current limits
statistics()supports count, mean, median, sum, standard deviation, variance, range, minimum, maximum, selected percentiles, IQR, skewness, and kurtosis.- Use
by groupvar:for grouped output in the current implementation. - The official
by()andformat()options are currently accepted by the parser but not applied; the compatibility entry is marked partial. - Weighted output is currently limited to supported count, mean, sum, minimum, and maximum calculations.
See the current tabstat entry and Stata's tabstat manual for the broader official behavior.
Related guides
Run this exact example
Clone the example repository in stats.camp and open the exact do-file shown on this page. No stats.camp account is required.
Open this example