tabulate: one-way and two-way frequency tables

Count categories, inspect their percentages, and cross-classify two categorical variables before moving to a model.

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

Run the frequency-table example View supported commands
Independent software. Not affiliated with, sponsored by, or endorsed by StataCorp LLC.

Create a frequency table with tabulate

The example uses 24 synthetic records with four race categories and a zero/one female indicator.

clear
import delimited "data/student_scores.csv"
tabulate race
tabulate race female

The first command describes one variable. The second cross-classifies each observed race value with each observed value of female.

Output from stats.camp

       race |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |          6       25.00       25.00
          2 |          6       25.00       50.00
          3 |          6       25.00       75.00
          4 |          6       25.00      100.00
------------+-----------------------------------
      Total |         24      100.00

           |        female
      race |         0          1 |     Total
-----------+----------------------+----------
         1 |         3          3 |         6
         2 |         3          3 |         6
         3 |         3          3 |         6
         4 |         3          3 |         6
-----------+----------------------+----------
     Total |        12         12 |        24

How to read the tables

The one-way table shows six records, or 25% of the dataset, in each race category. The cumulative percentage reaches 100% after category 4. In the two-way table, every race category contains three records with female=0 and three with female=1.

This balance was designed into the synthetic teaching data. A table describes the sample; it does not by itself establish that two variables are associated in a population.

Missing values and current limits

See the current tabulate entry and Stata's manuals for one-way and two-way tables for external references.

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 frequency-table example