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

detail
Replace the compact table with a distribution summary for each variable: the 1st, 5th, 10th, 25th, 50th, 75th, 90th, 95th, and 99th percentiles; up to four smallest and largest values; the mean, standard deviation, variance, skewness, and kurtosis. The 50th percentile is the median.
[fw=weightvar]
Treat an observation as repeated according to its frequency weight. Weights must be nonnegative integers; the reported observation count is the sum of the included weights. Place the weight before the comma.
[aw=weightvar]
Use analytic weights to calculate weighted summaries. The observation count is the number of included rows, while the weight total is reported separately. Missing and zero weights are excluded.
[iw=weightvar]
Use importance weights for a compact summary. This weight type cannot be combined with detail. Probability weights are not accepted by summarize.

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
Open example in browser

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.

Example result
VariableObservationsMeanMinimumMaximum
math2457.3754372
read2456.16674468
write2357.65224670