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:
- create a table showing mean scores per group -you'll probably want to include the frequencies and standard deviations as well;
- create a chart showing mean scores per group;
- 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.
Creating a Means Table
For creating a table showing means per category, we could mess around with syntax is as simple as it gets. So let's just run it and inspect the result.
but its not worth the effort as themeans q1 by jtype
/cells count mean stddev.
Note that you could easily add more statistics to the CELLS subcommand such as
Result
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 stacked bar chart with percentages.
and avoid the Chart Builder whenever I can -which is pretty much always unless I need a
In the dialog shown below, selecting
Basic Bar Chart Means by Category Syntax
GRAPH
/BAR(SIMPLE)=MEAN(q1) BY jtype
/TITLE='Mean Employee Care Rating by Job Type'
/SUBTITLE='N = 423'.
Result
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 ctemplate "bar-chart-means-trans-720-1.sgt".
*Rerun chart with template set.
GRAPH
/BAR(SIMPLE)=MEAN(q1) BY jtype
/TITLE='Mean Employee Care Rating by Job Type'
/SUBTITLE='N = 423'.
Result
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 for SPSS.
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!
THIS TUTORIAL HAS 12 COMMENTS:
By Ruben Geert van den Berg on May 29th, 2020
Hi Petter!
You can do so by using Graphs - Chart Builder instead of the legacy dialogs.
By Jon Peck on April 11th, 2022
If you create a means table but then want a chart, do this.
1. double click the table, opening the pivot table editor
2. highlight the Mean column or part of it
3. Right click and choose Create Graph > Bar
This is particularly convenient when you want only some of the rows to appear in the chart.
In the Chart Builder
1. double click the bar icon
2.drag the category variable to the x axis and the scale variable to the y axis
3. click ok.
Not so hard.
l
By Ruben Geert van den Berg on April 12th, 2022
Hi Jon!
Thanks for the suggestion but I'm really opposed to doing basically anything in SPSS without saving the syntax.
For selecting categories, I'd probably go for TEMPORARY and FILTER.
P.s. a really nice addition to SPSS would be tablelooks and chart templates from URLs. Allowing only local files whose paths may need to be looked up seems too hard for most users and strikes me as pretty outdated. That's such a pity because especially chart templates are among the most precious hidden SPSS gems -IMHO anyway...
By Jon Peck on April 12th, 2022
I wouldn't suggest using the pivot table editor to create charts as a regular solution. That method was intended for a quick, ad hoc chart as it is easier than filtering etc.
As for url's for tablelooks, that would make sense for all filetypes. Currently, you can get data via the SPSSINC_GETURI_DATA extension command but not other filetypes directly. More web scraping capability would be nice, but data appear in such a wide variety of formats and structures, it would be hard to craft a general solution.
By Jifar Bezabe Tibo on April 13th, 2022
Nice tutorial