summarize: descriptive statistics and missing values

Calculate counts, means, standard deviations, minima, and maxima for the full dataset or separately within groups.

Tested 2026-08-16 with the current stats.camp development build · View the do-file on GitHub

Run the grouped summary example View supported commands
Independent software. Not affiliated with, sponsored by, or endorsed by StataCorp LLC.

Complete example

The synthetic data contain 24 rows. One value of write is deliberately missing so the output shows that summarize uses the nonmissing observations of each variable.

clear
import delimited "data/student_scores.csv"
summarize math read write
by race: summarize math
summarize math, detail

Output from stats.camp

    Variable |        Obs        Mean   Std. dev.        Min        Max
-------------+---------------------------------------------------------
        math |         24      57.375    7.654567         43         72
        read |         24    56.16667    6.349712         44         68
       write |         23    57.65217     6.69877         46         70

write reports 23 observations while math and read report 24. Its mean and standard deviation are calculated from those 23 nonmissing values.

Summarize variables by group

Prefix the command with by race: to calculate the same statistics separately for each observed race value:

by race: summarize math
race   Variable   Obs      Mean   Std. dev.   Min   Max
   1   math         6     50.50      6.5345    43    60
   2   math         6     60.50      5.1284    53    67
   3   math         6     54.33      5.3914    47    62
   4   math         6     64.17      6.0470    56    72

Each group contains six observations. Grouping changes the calculation sample for each row of output; it does not replace the dataset in memory.

Current behavior of detail

The parser currently accepts summarize math, detail, but the current stats.camp renderer still returns only the basic count, mean, standard deviation, minimum, and maximum row:

    Variable |        Obs        Mean   Std. dev.        Min        Max
-------------+---------------------------------------------------------
        math |         24      57.375    7.654567         43         72

Percentiles, variance, skewness, and kurtosis from Stata's detailed display are not yet produced. The compatibility table marks this command partial until that output is implemented.

Checks and limits

Use the t-test guide for mean comparisons or the rank-sum guide for an independent-groups rank test. See the current summarize entry before relying on option-level parity.

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.

Run the grouped summary example