Command reference
tabstat — choose statistics for a summary table
Build a compact table containing the descriptive statistics you choose. Compare several variables, summarize groups, or switch the table so variables appear in columns.
Syntax
tabstat varlist [if condition] [in range] [weight] [, options]
by groupvars: tabstat varlist [, options]
List the numeric variables after tabstat. Add options after the comma. if and in restrict the observations before statistics are calculated. For grouped summaries, use either the by() option or a by groupvars: prefix.
Options
Example
The example compares math, reading, and writing scores in 24 synthetic student records, then requests counts, means, and standard deviations for math within each race code.
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)
Sample data included. Opens in a new tab; click Run.
What to look for
The first table gives 24 observations for math and reading but 23 for writing because one writing score is missing. Each race group has six math scores. Their means range from 50.50 to about 64.17; the standard deviations describe variation within those groups.