Hi all,
I'm new to the forum and still relatively new to SPSS as well. At the moment I am starting to get to grips with syntax in an effort to customize some charts beyond the standard options.
I managed to change the syntax to get a bar chart that is both clustered and stacked. Quick description of the data setup (slightly altered for confidentiality): x Axis shows four regions (North, South, West, East). In each region, there are three bars (Bachelor, Master, PhD), that describe 100% of students in that region. Each of these bars is stacked by gender (male female).
What I want the data labels to do is the following:
1. For each bar, show the % within that region at the top (the three bars must sum to 100%), so for example:
North --> 70% Bachelor, 12% Master, 18% PhD (showing at the top of each bar - not actual data, I am simulating at the moment)
2. Then within each bar, I want the % breakdown by gender, e.g. for North, Bachelor:
53% Female, 47% Male.
Reason: I want to be able to compare the gender breakdown within each education tier across regions, while also comparing the tier breakdown itself across regions at the same time. So for example, even though the amount of female Master students and female PhD students as a percentage of all North students is the same, the labels do make clear that the rate of females as a percentage of all PhD students in North is lower than as a rate of all Master students in North. (Hope this makes sense)
See attached for a visual example - I edited the chart in MS Word and have just added label for North to save time, I hope it makes clear what I am talking about.
Now finally the question: Is it possible to achieve this type of labeling, either through the menu or through syntax?
I have so far used the following code to generate the chart. Problem is, this is giving me the percentage for each "part of each bar" as a percentage of all students in a region, so the bar for North & Bachelor shows 37% in the female section and 33% in the male section
* Chart Builder.
GGRAPH
/GRAPHDATASET NAME="graphdataset" VARIABLES=region COUNT()[name="COUNT"] educ gender MISSING=LISTWISE
REPORTMISSING=NO
/GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
SOURCE: s = userSource(id("graphdataset"))
DATA: Office = col(source(s), name("region"), unit.category())
DATA: Tier = col(source(s), name("educ"), unit.category())
DATA: Bid = col(source(s), name("gender"), unit.category())
DATA: COUNT = col(source(s), name("COUNT"))
COORD: rect(dim(1, 2), cluster(3, 0))
SCALE: linear(dim(2), include(0))
GUIDE: axis(dim(2), label("Percent"))
GUIDE: axis(dim(3), label("region"))
GUIDE: legend(aesthetic(aesthetic.color.interior), label("educ"))
GUIDE: legend(aesthetic(aesthetic.texture.pattern.interior),
label("gender"))
ELEMENT: interval.stack(position(summary.percent(educ*COUNT*region, base.coordinate(dim(3)))),
color.exterior(color.black),
color.interior(educ), texture.pattern.interior(gender))
END GPL.
Any help on how I may alter this code to get the desired labeling would be very much appreciated. Thanks to all for reading!
Unrecoverable application error in the Statistics processor. 7 Answers
SPSS 20 - How do I automate exporting of specific tables to excel? 3 Answers
missing data 2 Answers
Case by Case Comparison Calcualtions using Syntax 4 Answers
GET DATA strange behaviour 3 Answers