How-to
SPSS CROSSTABS Syntax, Explained (With a Free Alternative)
The SPSS CROSSTABS command builds a contingency table from two categorical variables: /TABLES names the row and column variables, /STATISTICS requests tests like the chi-square, and /CELLS controls what each cell displays — counts, percentages, expected counts, and residuals.
Reviewed by the crosstabs.com methods team · Last updated
The canonical syntax
This is the CROSSTABS block most analysts actually want — a full crosstab with the chi-square test, effect sizes, and enough cell detail to interpret the result. Replace row and colwith your variable names and paste it into a syntax window (File → New → Syntax), then run it with Ctrl+R:
CROSSTABS /TABLES=row BY col /STATISTICS=CHISQ PHI LAMBDA /CELLS=COUNT ROW COLUMN EXP ASRESID.
The trailing period matters — it terminates the command. Each line starting with a slash is a subcommand that modifies what CROSSTABS produces.
What each subcommand does
/TABLES=row BY col
Defines the table. The variable before BY goes on the rows, the one after BY on the columns. You can list several variables on either side (CROSSTABS /TABLES=q1 q2 BY region) to produce one table per pair, or add a second BY for layered subtables.
/STATISTICS=CHISQ
Requests the Chi-Square Tests table: Pearson chi-square with df and two-sided asymptotic significance, the likelihood-ratio chi-square, and the linear-by-linear association test. For 2×2 tables SPSS adds Yates' continuity correction and Fisher's exact test automatically.
/STATISTICS=PHI
Adds the Symmetric Measures table with the phi coefficient and Cramér's V — the effect sizes that tell you how strong the association is, which the chi-square p-value alone does not. Phi applies to 2×2 tables; Cramér's V generalizes to larger tables.
/STATISTICS=LAMBDA
Adds Goodman and Kruskal's lambda, a proportional-reduction-in-error measure: how much better you can predict the row variable once you know the column variable (and vice versa, plus a symmetric version). A lambda of 0.25 means 25% fewer prediction errors.
/CELLS=COUNT ROW COLUMN EXP ASRESID
Controls what prints inside each cell: the observed COUNT, ROW and COLUMN percentages, the EXPected count under independence, and the Adjusted Standardized RESIDual. The defaults show counts only; this keyword list is what turns the table into something you can actually interpret.
Reading the output
SPSS prints three tables. The Crosstabulation table shows your cells: compare percentages in the direction of your grouping variable (column percentages if groups are columns — see how to read a crosstab). Adjusted residuals beyond ±1.96 flag the cells driving any association.
The Chi-Square Teststable is where most people look first. Read the “Pearson Chi-Square” row: the Value column is χ², df is the degrees of freedom, and “Asymptotic Significance (2-sided)” is the p-value. Check the footnote beneath it — if it says some cells have expected counts below 5, see what to do about expected counts less than 5 (for 2×2 tables, report the Fisher's Exact Test row instead).
Finally, the Symmetric Measurestable reports phi, Cramér's V, and lambda. Report Cramér's V alongside the p-value: with a large sample, a chi-square test can be significant even when the association is trivially small.
Common errors
Missing the terminating period
Every SPSS command must end with a period. Omit it and SPSS either reports a syntax error or silently swallows the next command into this one.
Misspelled variable names
"Undefined variable name" means the name in /TABLES doesn't match the dataset. Check the Variable View tab — SPSS variable names have no spaces, and you must use the name, not the label.
Crosstabbing a scale variable
CROSSTABS will happily make a table with one row per distinct value of a continuous variable, producing a sprawling, useless table. Recode continuous variables into bands first (RECODE or visual binning), or rethink the analysis.
Reading the wrong percentage
When you request both ROW and COLUMN percentages, each cell shows several numbers and it is easy to quote the wrong one. The output labels each line ("% within row-variable"); compare percentages within your grouping variable.
Ignoring the expected-count footnote
The chi-square p-value is printed whether or not its assumptions hold. The footnote about cells with expected counts below 5 is the assumption check — don't report the Pearson result from a 2×2 table that fails it when Fisher's exact test is sitting two rows lower.
No SPSS license? The free alternative
If you only need crosstabs — not the rest of SPSS — you don't need a license at all. Upload a CSV or XLSX to our free SPSS crosstab alternative and you get the same output this syntax produces: observed counts, row and column percentages, expected counts, adjusted residuals with significant cells highlighted, the chi-square test, and Cramér's V. Everything runs in your browser and your file never leaves your device. For a single table you already have as counts, the chi-square calculator is even quicker.
Frequently asked questions
- What does /CELLS=COUNT ROW COLUMN EXP ASRESID mean in SPSS?
- It controls what appears inside each cell of the crosstab: COUNT shows the observed count, ROW the row percentage, COLUMN the column percentage, EXP the expected count under independence, and ASRESID the adjusted standardized residual. Cells with |adjusted residual| > 1.96 depart significantly from independence at the 0.05 level.
- How do I get a chi-square test from SPSS CROSSTABS?
- Add the /STATISTICS=CHISQ subcommand. SPSS then prints a Chi-Square Tests table with the Pearson chi-square, likelihood-ratio chi-square, and linear-by-linear association test; for 2×2 tables it adds the continuity correction and Fisher's exact test. Read the 'Pearson Chi-Square' row and its 'Asymptotic Significance (2-sided)' column for the standard test.
- Why does SPSS say 'cells have expected count less than 5'?
- It is a footnote under the Chi-Square Tests table warning that the chi-square approximation may be unreliable because some expected counts are small. The convention is that no more than 20% of cells should have expected counts below 5 and none below 1. For a 2×2 table that fails the check, report Fisher's exact test instead.
- Can I run CROSSTABS on more than two variables?
- Yes. The TABLES subcommand accepts layers: /TABLES=row BY col BY layer produces a separate row-by-column subtable for each category of the layer variable. You can chain up to several BY keywords, though tables become hard to read beyond one layer.
References & further reading
- CROSSTABS — IBM SPSS Statistics Command Syntax Reference
- Cochran, W. G. (1954). Some methods for strengthening the common χ² tests. Biometrics, 10(4), 417–451.