Running simple contingency tables in SPSS is easy enough. However, the default format is inconvenient and doesn't meet APA standards. This tutorial walks you through 3 options for creating the desired tables:
- CROSSTABS is easy but requires some (manual) editing.
- CTABLES is faster but a bit harder and requires a custom tables license.
- TABLES is fast but rather challenging.
We'll use bank_clean.sav -partly shown below- for all examples. You can try them yourself after downloading the data.
So What Are Contingency Tables Anyway?
Contingency tables show frequencies for all
combinations of values of 2(+) variables. For example, the table below shows a contingency table -or “crosstab”- for 2 variables: marital status and education level.
Only 1 respondent had middle school and never married;
A total of 123 respondents never married;
Only 4 respondents have middle school or lower;
The table shows all combinations of marital status and education for 442 respondents.
Hopefully, contingency tables give some insight into the association -if any- between these variables. So how does that work? For a very simple explanation, see
Running Simple Contingency Tables in SPSS
The fastest way to create the table we just saw is running one line of SPSS syntax: crosstabs educ by marit. The categories of the first variable -educ or education- become rows in the table. The values of the second variable -marit or marital status- become the columns. As a rule of thumb, the columns hold the groups you want to compare on whatever goes into the rows. In this case, we're comparing marital status groups on education level.
If we had wanted to do the reverse -compare education level groups on marital status- we'd swap the rows and columns and run crosstabs marit by educ.
CROSSTABS with Column Percentages
Right. So how do our groups compare on education level? It's hard to see from our first table because each marital status group has a different n or sample size. We may see more of a pattern if we add column percentages. The syntax below does just that.
*Create contingency table with frequencies and column percentages.
crosstabs educ by marit
/cells count column.
If we study the entire table, it seems that widowed respondents are somewhat higher educated than the others: no less than 56.8% hold a master's degree and another 13.5% even a PhD. The overall pattern is not very clear though and we'd perhaps better visualize it as a stacked bar chart.
In any case, the table format -percentages in rows- doesn't really help either and doesn't meet APA guidlines. So let's fix it.
Converting CROSSTABS to APA Tables
One solution is right-click our table and selectIn the pivot editor that opens, tick as shown below.
Now drag and drop statistics right underneath Marital status and just close the window.
Let's now make 2 text replacements:
- use n instead of “Count”
- use % instead of “% within Marital status”
Using the Ctrl + H shortkey in the output viewer should work. Or -much nicer- use the OUTPUT MODIFY syntax below if you're on SPSS version 22 or higher.
/tablecells select = ['% within Marital status'] replace = '%' applyto = columnheader
/tablecells select = ['Count'] replace = 'n' applyto = columnheader.
ResultAPA Contingency Table Created with CROSSTABS
So that's the easiest way to create an APA style contingency table in SPSS. But -personally- I find it too much work, especially for several tables. So let's consider 2 alternatives.
APA Contingency Tables from CTABLES
The table we just created can be run in one go with CTABLES. However, this only works if you've a license for the custom tables module. You can check this by running show license. If the resulting table includes “Custom Tables”, try the syntax below.
/table educ by marit [count 'n' colpct '%']
/categories variables = educ marit total = yes.
ResultAPA Contingency Table Created with CTABLES
CTABLES works great for this table but -unfortunately- you'll need a separate command for each table. The syntax is also somewhat challenging. I think you could paste it from
A better way perhaps is to copy-paste-edit the syntax example for several tables. Or create and run the commands with Python for SPSS. This is faster but also harder. But if you like it fast and hard -I surely do- then go for it.
APA Contingency Tables from TABLES
So what if you don't have a license for CTABLES? Well, then there's TABLES. TABLES was replaced by CTABLES around 1990 and removed from all documentation. But -as very very few SPSS users know- TABLES still works in all recent SPSS versions.
Like so, the syntax below is an alternative for the CTABLES approach.
/ftotal = ftot 'Total'
/table educ + ftot by marit > (statistics) + ftot
/statistics count((f3) 'n') cpct((pct5.1) '%':marit).
ResultAPA Contingency Table Created with TABLES
This contingency table is almost identical to the CTABLES result. Unfortunately, the syntax is even harder and -worse- not documented. We might build a tool for creating the TABLES command from the menu but it won't come up any time soon.
We showed 3 ways for creating APA style contingency tables in SPSS:
- CROSSTABS is easiest. You can create several tables in one go but they require quite some (manual) editing.
- CTABLES runs the desired table straight away and could be run from the menu. However, it creates one table at the time and requires an additional license.
- TABLES also comes up with the right table straight away. However, the syntax is difficult and there's no menu.
Admittedly, none of these options is ideal. So we might build a tool some time that runs many tables in one go from the menu.
Thanks for reading!