我想创建stlak条形图,具有HSB,OHS,RES的WORKSCOPE列。但我想按照茎杆中OHS,HSB,RES的顺序重新排序WORKSCOPE。通常默认按字母顺序排列。我怎样才能实现它。
goptions reset=all;
goptions colors=(red blue green);
legend1 label=none
order=('OHS' 'HSB' 'RES');
proc gchart data=FINALREPV3;
vbar year / discrete type=sum sumvar=VALUE
subgroup=WORKSCOPE legend=legend1 ;
run;
答案 0 :(得分:0)
您可以预先创建排序变量,使用它对输入数据进行排序,然后使用proc sgplot
xaxis discreteorder = data
进行绘图。
/* Create dummy sorting variable */
data want;
set finalrepv3;
if workscope = "OHS" then _sort = 1;
if workscope = "HBS" then _sort = 2;
if workscope = "RES" then _sort = 3;
run;
/* Put the data in the required order */
proc sort data = want;
by _sort;
run;
/* Create the plot */
proc sgplot data = want;
vbar year / group = workscope response = value stat = sum;
/* Request that the x axis respect the data's order */
xaxis discreteorder = data;
run;