Command reference
summarize — describe numeric variables
Calculate observation counts, means, standard deviations, and ranges. Use a detailed summary to examine percentiles and the shape of a distribution.
Syntax
summarize [varlist] [if condition] [in range] [weight] [, detail]
by groupvars: summarize varlist [, detail]
varlist names the variables to summarize; omit it to inspect all variables. if selects observations by a condition, and in selects positions in the current row order, such as in 1/20. A by prefix calculates a separate summary for each group. The aliases sum and su also work.
Options
Example
The example loads 24 synthetic student records, summarizes three scores, compares math scores across the four race codes, and requests a detailed math summary. One writing score is deliberately missing.
clear
import delimited "data/student_scores.csv"
summarize math read write
by race: summarize math
summarize math, detail
Sample data included. Opens in a new tab; click Run.
What to look for
Math and reading use all 24 records; writing uses 23. The grouped command reports a separate mean and spread for each race code. The final detail command adds percentiles, helping you see where the middle of the math distribution lies and whether extreme values are far from it.
| Variable | Observations | Mean | Minimum | Maximum |
|---|---|---|---|---|
| math | 24 | 57.375 | 43 | 72 |
| read | 24 | 56.1667 | 44 | 68 |
| write | 23 | 57.6522 | 46 | 70 |