BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
CLiu
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

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

2 REPLIES 2
Jay54
Meteorite | Level 14

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.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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