Question & Answer
Question
I used to create pie charts with median as summary statistics and to have separate variables in one pie chart. On the legacy pie charts this can be done with Graphs - Legacy dialogs - Pie - Summaries of separate variables. I paste the syntax and changed the summary Statistics to SUM as in this example: GET FILE = 'C:\Program Files\IBM\SPSS\Statistics\22\Samples\English\Employee data.sav'. GRAPH /PIE=Median(educ) Median(jobcat) /MISSING=LISTWISE. How to do this with Chart Builder and GGRAPH?
Answer
This is possible with the Syntax provided below. In the menus go to Graphs - Chart Builder, select a pie chart. On the variables list select the variables you would like to have in the chart, right click on selection and click "scale". Drag and drop the selection onto the y axis of the pie chart to create a summary group. On the element properties dialog select "Sum" as summary Statistics, click Apply and paste the syntax.
On the pasted syntax change the statistics from SUM to MEDIAN on the graphdataset subcommand like in the example below. Run the syntax and edit the chart in the viewer. After creation it is necessary to click on "Show Data Labels" on the chart editor and to select "Median" as the displayed statistics. It is possible to create a chart template with these option enabled.
* Chart Builder.
GGRAPH
/GRAPHDATASET NAME="graphdataset" VARIABLES=MEDIAN(educ) MEDIAN(jobcat) MISSING=LISTWISE
REPORTMISSING=NO
TRANSFORM=VARSTOCASES(SUMMARY="#SUMMARY" INDEX="#INDEX")
/GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
SOURCE: s=userSource(id("graphdataset"))
DATA: SUMMARY=col(source(s), name("#SUMMARY"))
DATA: INDEX=col(source(s), name("#INDEX"), unit.category())
COORD: polar.theta(startAngle(0))
GUIDE: axis(dim(1), null())
GUIDE: legend(aesthetic(aesthetic.color.interior), label(""))
SCALE: linear(dim(1), dataMinimum(), dataMaximum())
SCALE: cat(aesthetic(aesthetic.color.interior), include("0", "1"))
ELEMENT: interval.stack(position(summary.percent(SUMMARY))), color.interior(INDEX))
END GPL
Related Information
Was this topic helpful?
Document Information
More support for:
IBM SPSS Statistics
Software version:
22.0, 21.0, 20.0, 19.0
Document number:
423939
Modified date:
16 April 2020
UID
swg21484989