By Ruben Geert van den Berg on December 18, 2016 under Blog.

SPSS Bar Charts Tutorial

SPSS Bar Chart Styled

One of the best known charts is a simple bar chart containing frequencies or percentages. The easiest way to run it in SPSS is the FREQUENCIES command. This tutorial walks you through some options. We'll use freelancers.sav throughout, part of which is shown below.

SPSS Bar Chart Tutorial Data View

Option 1: FREQUENCIES

In most cases, a simple FREQUENCIES command is our best option because it takes multiple variables in one go. Its syntax -shown below- is so simple that just typing it is probably faster than messing around with the menu.

*Easiest way to run 5 bar charts.

frequencies sector_2010 to sector_2014
/format notable
/barchart.

Result - Basic

SPSS Bar Chart Unstyled 600

Unsurprisingly, we created the desired bar charts but -like most SPSS charts- they look awful. A great way to fix that is using an SPSS chart template. Just one template is sufficient for having pretty bar charts for once and for all.
A chart template can also transpose (“put on its side”) our chart, which works much better for bar charts than SPSS’ default orientation. One of the charts that resulted from the template we built is shown below.

Result - Chart Template

SPSS Bar Chart Styled

Sorting Categories and Percentages

A nice -albeit little known- option is sorting the categories. If we transpose our chart, we can sort our bars by descending frequency by specifying /FORMAT NOTABLE AFREQ (use DFREQ for untransposed charts).
Second, we can have percentages instead of frequencies by using /BARCHART PERCENT as shown in the syntax below.

Sorted Bar Charts with Percentages Syntax

*Bar chart percentages, sorted by ascending frequency ("afreq").

frequencies sector_2010
/format notable afreq
/barchart percent.

Result

SPSS Bar Chart Percentages Styled

Note: the %-sign is missing from our chart but we can fix this by modifying our chart template.

Option 2: GRAPH

When we run bar charts with FREQUENCIES, the variable labels of the variables involved are used as chart titles. If we want custom titles instead, we're perhaps better off by using GRAPH.Alternatively, set the desired chart titles as new variable labels. Preceding this with TEMPORARY restores the old labels. Since its syntax is a bit more difficult, we'll generate it from the menu as shown below.

SPSS Graphs Legacy Dialogs Bar 840 SPSS Bar Chart Frequencies Legacy Dialog

Resulting Syntax

*Bar chart syntax from legacy dialog.

GRAPH
/BAR(SIMPLE)=PCT BY sector_2010
/TITLE='All Respondents | n = 40'.

Note: unfortunately, GRAPH takes only one variable at the time. However, we can remove the line breaks from the syntax and copy-paste-edit it a couple of times for a handful of variables. For running charts or tables over many variables, see SPSS Python Loop Examples.
Second, GRAPH does not allow us to sort our categories but a chart template can fix that.

SPSS Bar Charts - Chart Sizes

One issue with all SPSS charts is that their sizes are fixed in pixels. However, a bar chart for many categories needs more space than a chart for few categories. In fact, categories may disappear altogether if they don't fit into the chart anymore. SPSS does not offer a solution for this other than “stretching” each chart manually in the output viewer. For a better solution, see SPSS - Set Chart Sizes Tool.
With respect to the layout of reports, we prefer having the heights (rather than the widths) of our charts depend on the amount of content they contain. This is yet another good reason for always transposing our bar charts.

Conclusion

In most cases, typing a simple FREQUENCIES command is by far the best option for creating bar charts. GRAPH as pasted from Graphs SPSS Menu Arrow Legay Dialogs is a reasonable option too.
As with most charts, Graphs SPSS Menu Arrow Chart Builder is better avoided since it's way more complicated and results in the exact same chart as the aforementioned options.

Bar Charts - FREQUENCIES Versus GRAPH

The table below quickly summarizes the differences between the two options we discussed in this tutorial.

FeatureFREQUENCIESGRAPH
Multiple variablesYesNo
Category sortingYesOnly with chart template
Percent signsOnly with chart templateYes
Custom chart titleNoYes

Comment on this Tutorial

*Required field. Your comment will show up after approval from a moderator.

This Tutorial has 4 Comments