Sample 25519: Control the midpoint order on the Legend using the ORDER= option
This sample is from the "SAS/GRAPH Software: Reference, Version 8", Volume 1, Chapter 13.
For additional information on the sample refer to this book.
/*+-------------------------------------------------------+
| S A S S A M P L E L I B R A R Y |
| |
| NAME: GCHLEGND |
| TITLE: GCHLEGND-Patterns and Midpoints in a Legend |
| PRODUCT: GRAPH |
| SYSTEM: ALL |
| KEYS: GRAPHICS GCHART |
| PROCS: GCHART |
| DATA: INTERNAL |
| |
| SUPPORT: GRAPHICS STAFF UPDATE: |
| REF: SAS/GRAPH REFERENCE GUIDE |
+-------------------------------------------------------+*/
/* Set selected graphics options for the examples */
goptions reset=all gunit=pct border cback=white
colors=(black blue green red) ftitle=swissb
ftext=swiss htitle=5 htext=4;
/* Create data set ENPROD */
data enprod;
input @1 year 4. @6 engytype $8. @16 produced 5.2;
datalines;
1985 Coal 19.33
1985 Gas 19.22
1985 Petro 18.99
1985 Nuclear 4.15
1985 Hydro 2.97
1985 Geotherm .20
1985 Biofuels .01
1995 Coal 21.98
1995 Gas 21.54
1995 Petro 13.89
1995 Nuclear 7.18
1995 Hydro 3.21
1995 Geotherm .31
1995 Biofuels 2.95
;
/* Define a title and footnote */
title1 'Principle Sources of Energy: 1985';
title2 font=swissb h=4.5 '(Amounts in quadrillion btu)';
footnote h=3 j=r 'GCHLEGND ';
/* Define pattern color for each energy type */
pattern1 color=black; /* biofuels */
pattern2 color=blue; /* coal */
pattern3 color=green; /* gas */
pattern4 color=gray; /* geothermal */
pattern5 color=lipk; /* hydoelectric */
pattern6 color=lime; /* nuclear */
pattern7 color=cyan; /* petro */
pattern8 color=red; /* other */
/* Define a legend */
legend1 label=none
position=(left middle)
offset=(4,)
across=1
order=('Coal' 'Gas' 'Petro'
'Nuclear' 'Renewable')
value=(color=black)
shape=bar(4,4);
/* Create the pie chart */
proc gchart data=enprod(where=(year=1985));
pie engytype / sumvar=produced
other=5
otherlabel='Renewable'
descending
legend=legend1
value=inside
ctext=white
coutline=black
noheading;
run;
quit;

This example uses the ORDER= to order the legend values that appear in the Legend.
| Type: | Sample |
| Topic: | Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Elements ==> Legends Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Types ==> Charts ==> Pie SAS Reference ==> Procedures ==> GCHART
|
| Date Modified: | 2006-06-16 03:02:44 |
| Date Created: | 2005-05-23 14:12:51 |
Operating System and Release Information
| SAS System | SAS/GRAPH | All | 8 TS M0 | n/a |