SPSS tutorials website header logo SPSS TUTORIALS BASICS ANOVA REGRESSION FACTOR CORRELATION

SPSS – Stacked Bar Charts Percentages

SPSS Stacked Bar Chart - Example with Template Applied

Creating SPSS stacked bar charts with percentages -as shown above- is pretty easy. However, figuring out the right steps may take quite some effort and frustration. This tutorial therefore shows how to do it properly in one go.
We encourage you to follow along on course_evaluation.sav. Part of these data are shown in the screenshot below.

Screenshot of Practice Data File

Example: Course Rating by Study Major

Let's say we'd like to visualize the association between study major (nominal) and overall course rating (ordinal). A table that gives us some insight is a contingency table showing column percentages. We'll create it by running the syntax below.

*Show only labels in output.

set tnumbers labels tvars labels.

*Crosstab with column percentages.

crosstabs q1 by major
/cells column.

Result

SPSS Stacked Bar Chart - Crosstab

Our course was least popular with students studying some “Other” study major. Can you tell which students like our course most?
Anyway, it's exactly this table that we'll visualize as a chart. We'll do so by following the next five screenshots.

SPSS Chart Builder Dialogs

SPSS Stacked Bar Chart - Menu SPSS Stacked Bar Chart - Select Basic Chart SPSS Stacked Bar Chart - Set Measurement Level

Our stacked bar chart requires setting measurement levels to nominal or ordinal. You could do so before opening the chart builder (possibly preceded by TEMPORARY) or within the chart builder. When using this second option, the chosen measurement levels apply only to the chart you're creating.

SPSS Stacked Bar Chart - Add Variables SPSS Stacked Bar Chart - Transpose Chart

Transpose sort of rotates our chart by 90 degrees and thus changes the chart layout from vertical to horizontal. This isn't necessary but the horizontal layout is usually much more suitable for all sorts of bar charts than the default vertical layout.
Two options for transposing charts are 1) in the chart builder as we do now or 2) by applying an SPSS chart template.

SPSS Stacked Bar Chart - Select Percentages Don't forget to “Apply” here -like I always do.

The steps in the screenshot above show the steps for selecting the right percentages for this chart. Don't forget to click Apply whenever changing something in the Element Properties dialog (we forget it all the time).

SPSS Stacked Bar Chart - Add Main Title And again: “Apply”.

Optionally, set a main title for the chart and Apply it. Clicking Paste results in the syntax below. Let's run it.

SPSS Stacked Bar Chart Syntax

* Chart Builder.
GGRAPH
/GRAPHDATASET NAME="graphdataset" VARIABLES=major COUNT()[name="COUNT"] q1[LEVEL=ORDINAL]
    MISSING=LISTWISE REPORTMISSING=NO
/GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
SOURCE: s=userSource(id("graphdataset"))
DATA: major=col(source(s), name("major"), unit.category())
DATA: COUNT=col(source(s), name("COUNT"))
DATA: q1=col(source(s), name("q1"), unit.category())
COORD: rect(dim(1,2), transpose())
GUIDE: axis(dim(1), label("What's currently your (primary) major?"))
GUIDE: axis(dim(2), label("Percent"))
GUIDE: legend(aesthetic(aesthetic.color.interior), label("How do you rate this course?"))
GUIDE: text.title(label("Course Ratings by Study Major"))
SCALE: cat(dim(1), include("1", "2", "3", "4", "5"))
SCALE: linear(dim(2), include(0))
SCALE: cat(aesthetic(aesthetic.color.interior), include("1", "2", "3", "4", "5"))
ELEMENT: interval.stack(position(summary.percent(major*COUNT, base.coordinate(dim(1)))),
    color.interior(q1), shape.interior(shape.square))
END GPL.

Unstyled Stacked Bar Chart

SPSS Stacked Bar Chart - Unstyled

First, note that “Very bad” appears in our legend even though it's not present in our data. By default, the Chart Builder includes all values for which value labels are present regardless whether they are present in the data. This can be very annoying: any categories you excluded with FILTER now reappear in your chart.
Second, our chart looks terrible (however, see New Charts in SPSS 25 - How Good Are They Really?). However, a chart template is a great way to fix that. The end result is shown below.

Styled Stacked Bar Chart

SPSS Stacked Bar Chart - Styled

Unfortunately, our chart doesn't show any association at all -a bit of an anticlimax after all the work. But I hope you'll have more luck with your charts!

Thanks for reading!

Tell us what you think!

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

THIS TUTORIAL HAS 12 COMMENTS: