SPSS Tutorials


Creating Bar Charts with Means by Category

One of the most common research questions is do different groups have different mean scores on some variable? This question is best answered in 3 steps:

  1. create a table showing mean scores per group -you'll probably want to include the frequencies and standard deviations as well;
  2. create a chart showing mean scores per group;
  3. run some statistical test -ANOVA in this case. However, this is only meaningful if your data are (roughly) a simple random sample from your target population.

We'll show the first 2 steps using an employee survey whose data are in bank_clean.sav. The screenshot below shows what these data basically look like.

SPSS Data View Bank Clean

Creating a Means Table

For creating a table showing means per category, we could mess around with Analyze SPSS Menu Arrow Compare Means SPSS Menu Arrow Means but its not worth the effort as the syntax is as simple as it gets. So let's just run it and inspect the result.

*Create table with mean ratings by job type.

means q1 by jtype
/cells count mean stddev.


Note: we set a table template before running the table shown below.

SPSS Bar Chart Means By Category Means Table

Basically, our table tells us that the mean employee care ratings increase with higher job levels except for “upper management”. A proper descriptives table -always recommended- gives nicely detailed information. However, it's not very visual. So let's now run our chart.

SPSS Bar Chart Menu & Dialogs

As a rule of thumb, I create all charts from Graphs SPSS Menu Arrow Legacy Dialogs and avoid the Chart Builder whenever I can -which is pretty much always unless I need a stacked bar chart with percentages.

SPSS Graphs Legacy Dialogs Bar Menu

In the dialog shown below, selecting Other statistic... enables you to enter a dependent variable;
I usually include a title that describes what the chart is showing. I also throw in a subtitle that says which cases are included in my chart.

SPSS Bar Chart Means By Category Dialog

Basic Bar Chart Means by Category Syntax

*Bar chart means by category syntax.

/BAR(SIMPLE)=MEAN(q1) BY jtype
/TITLE='Mean Employee Care Rating by Job Type'
/SUBTITLE='N = 423'.


SPSS Bar Chart Means By Category With Chart Template

We now have our basic chart but it doesn't look too good.From SPSS version 25 onwards, it will look somewhat better. However, see New Charts in SPSS 25: How Good Are They Really? Yet. We'll fix this by setting a chart template.
Note that a chart template can also sort this bar chart -for instance by descending means- but we'll skip that for now.

Bar Chart Means by Category Syntax II

*Set chart template (make sure the .sgt file is in default folder as shown by SHOW DIR.).

set ctemplate "bar-chart-means-trans-720-1.sgt".

*Rerun chart with template set.

/BAR(SIMPLE)=MEAN(q1) BY jtype
/TITLE='Mean Employee Care Rating by Job Type'
/SUBTITLE='N = 423'.


SPSS Bar Chart Means By Category With Chart Template

Right, so that's about it. If you need a couple of similar charts, you could copy-paste-edit the last GRAPH command (no need to repeat the other commands). If you need many similar charts, you could loop over the GRAPH command with Python.
If you're going to run other types of charts, don't forget to set a different chart template. Or switch if off altogether by running set ctemplate none. Thanks for reading!

Previous tutorial: Xlrd (Python Module)

Next tutorial: SPSS ALTER TYPE Reporting Wrong Values?

Let me know what you think!

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

This tutorial has 2 comments