The sample code on the Full Code tab uses PROC FORMAT to reorder the stacked bars of a vertical bar chart. By default, the order of the stacked bars is alphabetical order based on the values of the SUBGROUP variable going from bottom to top. The legend displays the formatted values.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
/* Set the graphics environment */
goptions reset=all cback=white border htitle=12pt htext=10pt;
data sample;
input Midpoint Sub $;
datalines;
100 A
100 B
100 B
100 C
100 C
100 C
200 A
200 B
200 B
200 C
200 C
200 C
300 A
300 B
300 B
300 C
300 C
300 C
;
run;
proc sort data=sample out=new;
by descending sub;
run;
data ranked;
set new;
by descending sub;
if first.sub then Rank+1;
run;
proc format;
value ranked 1='C' 2='B' 3='A';
run;
proc gchart data=ranked;
vbar midpoint / discrete subgroup=rank raxis=axis1 width=6;
format rank ranked.;
axis1 minor=none label=(angle=90);
title1 'Use PROC FORMAT to reorder the subgroups';
run;
quit;
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> GCHART Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Types ==> Charts ==> Bar |
Date Modified: | 2011-09-09 12:28:55 |
Date Created: | 2004-11-11 11:07:54 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | SAS/GRAPH | All | n/a | n/a |