Data visualization with SAS programming

How to produce stacked bar charts with GROUP and SUBGROUP in SGPLOT?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

How to produce stacked bar charts with GROUP and SUBGROUP in SGPLOT?

I can produce a stacked bar charts with GROUP and SUBGROUP in GPLOT (see the figure and the dataset attached).

legend1 label=(height=3 'Drop-out Reasons');    

**pattern1 color=black value=e;                                                                  

pattern1 color=black value=r4;                                                                      

pattern2 color=red value=l4;

pattern3 color=blue value=x2;  

axis1 label = (height =2 "TRT" justify=center) value=(height=2) ;

axis2 order=(0 to 100 by 10) label=(angle=90 height=2.5 "Percent of Drop-out (%)") ;          

title1 "Figure 8.3. Stacked Bar Charts for the Distribution of Patient Drop-out Reasons by Treatment Group";

proc gchart data= dropout;

  vbar trt / sumvar=pct subgroup=reason group=visit

  MIDPOINTS= (1, 2, 3) width=8 space=0 gspace=6                                                                      

            maxis=axis1 raxis=axis2 legend=legend1;  

  format visit vstdf. reason rsndf. trt trtdf.;

  label visit = "Visit";

run;                                                                                                                                

quit;

However in SGPLOT there is only GROUP and no SUBGROUP option, the below codes do not work.

proc sgplot data=dropout;

  vbar visit / response = pct group=trt subgroup=reason ;

  keylegend / position=bottom noborder;

  xaxis label = "Drug";

  yaxis VALUES= (0 to 100 by 10) label = "Percent of Drop-out (%)";

  format visit vstdf. reason rsndf. trt trtdf.;

run;

quit;


Anyone know how to reproduce the same figure in SGPLOT?

Thanks,

Charlie


Accepted Solutions
Solution
‎12-21-2013 03:36 PM
SAS Super FREQ
Posts: 1,139

Re: How to produce stacked bar charts with GROUP and SUBGROUP in SGPLOT?

SGPLOT does not support CLUSTER and STACKED groups simultaneously.  This feature may be added in a future release.  However, you can create such a graph using the SGPANEL procedure.  See blog article on this topic.

View solution in original post


All Replies
Solution
‎12-21-2013 03:36 PM
SAS Super FREQ
Posts: 1,139

Re: How to produce stacked bar charts with GROUP and SUBGROUP in SGPLOT?

SGPLOT does not support CLUSTER and STACKED groups simultaneously.  This feature may be added in a future release.  However, you can create such a graph using the SGPANEL procedure.  See blog article on this topic.

Occasional Contributor
Posts: 17

Re: How to produce stacked bar charts with GROUP and SUBGROUP in SGPLOT?

Thanks.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 2048 views
  • 0 likes
  • 2 in conversation