How can I have this graph (Stacked Histogram) sorted on the variable MEAN(RowN) or MEAN(RowN_A) or MEAN(RowN_B) instead of on Var1?
Stacked Histogram Stacked Histogram
What I have tried so far: sorting the data in the dataset Variations of sort.values in the GPL SCALE command.
Below the code:
* Custom Tables.
CTABLES
/VLABELS VARIABLES=Var1 RowN RowN_A RowN_B DISPLAY=LABEL
/TABLE Var1 BY RowN [MEAN] + RowN_A [MEAN] + RowN_B [MEAN]
/CATEGORIES VARIABLES=Var1 ORDER=D KEY=VALUE EMPTY=EXCLUDE
/CRITERIA CILEVEL=95
/TITLES
TITLE='Percentages favorable, neutral, unfavorable'.
* Chart Builder.
GGRAPH
/GRAPHDATASET NAME="graphdataset" VARIABLES=Var1 MEAN(RowN) MEAN(RowN_A) MEAN(RowN_B)
MISSING=LISTWISE REPORTMISSING=NO
TRANSFORM=VARSTOCASES(SUMMARY="#SUMMARY" INDEX="#INDEX")
/GRAPHSPEC SOURCE=INLINE
/COLORCYCLE COLOR1(225,188,29), COLOR2(161,24,80), COLOR3(63,235,124), COLOR4(79,33,150),
COLOR5(0,158,154), COLOR6(0,114,195), COLOR7(208,176,255), COLOR8(0,97,97), COLOR9(250,117,166),
COLOR10(0,60,115), COLOR11(169,112,255), COLOR12(209,39,101), COLOR13(108,202,255),
COLOR14(110,50,201), COLOR15(1,186,182), COLOR16(118,11,57), COLOR17(17,147,232),
COLOR18(0,125,121), COLOR19(255,160,194), COLOR20(137,63,252)
/FRAME OUTER=NO INNER=NO
/GRIDLINES XAXIS=NO YAXIS=YES
/STYLE GRADIENT=NO.
BEGIN GPL
DATA: SUMMARY=col(source(s), name("#SUMMARY"))
DATA: INDEX=col(source(s), name("#INDEX"), unit.category())
COORD: rect(dim(1,2), transpose())
GUIDE: axis(dim(1), label("Var1"))
GUIDE: axis(dim(2), label("Mean"))
GUIDE: legend(aesthetic(aesthetic.color.interior), label(""))
SCALE: linear(dim(2), include(0))
SCALE: cat(aesthetic(aesthetic.color.interior), reverse(), include("0", "1", "2"))
ELEMENT: interval.stack(position(Var1*SUMMARY), color.interior(INDEX), shape.interior(shape.square))
END GPL.