Sample 25519: Control the midpoint order on the legend for a pie chart using the ORDER= option
The sample code on the Full Code tab uses the ORDER= option on a LEGEND statement with PROC GCHART to order the values that appear in the legend.
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.
This example uses the ORDER= option on a LEGEND statement with PROC GCHART to order the values that appear in the legend.
The graphics output in the Results tab was produced using SAS® 9.2. Submitting the sample code with other releases of SAS might produce different results.
/* Set the graphics environment */
goptions reset=all border cback=white htitle=12pt;
/* 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
;
run;
/* Define the titles */
title1 'Principle Sources of Energy: 1985';
title2 h=11pt '(Amounts in quadrillion btu)';
/* Define pattern color for each energy type */
pattern1 color=dabg; /* biofuels */
pattern2 color=vibg; /* coal */
pattern3 color=mob; /* gas */
pattern4 color=day; /* geothermal */
pattern5 color=deoy; /* hydoelectric */
pattern6 color=libg; /* nuclear */
pattern7 color=beige; /* petro */
pattern8 color=grp; /* 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,1.5);
/* Create the pie chart */
proc gchart data=enprod(where=(year=1985));
pie engytype / sumvar=produced
other=5
otherlabel='Renewable'
descending
legend=legend1
value=inside
coutline=black
noheading;
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.
This example uses the ORDER= option inn a LEGEND statement with PROC GCHART to order the values that appear in the legend.
Type: | Sample |
Topic: | 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 | z/OS | 9.1 TS1M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M0 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.1 TS1M0 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.1 TS1M0 | |
Microsoft Windows 2000 Advanced Server | 9.1 TS1M0 | |
Microsoft Windows 2000 Datacenter Server | 9.1 TS1M0 | |
Microsoft Windows 2000 Server | 9.1 TS1M0 | |
Microsoft Windows 2000 Professional | 9.1 TS1M0 | |
Microsoft Windows NT Workstation | 9.1 TS1M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.1 TS1M0 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.1 TS1M0 | |
Microsoft Windows Server 2003 Standard Edition | 9.1 TS1M0 | |
Microsoft Windows XP Professional | 9.1 TS1M0 | |
64-bit Enabled AIX | 9.1 TS1M0 | |
64-bit Enabled HP-UX | 9.1 TS1M0 | |
64-bit Enabled Solaris | 9.1 TS1M0 | |
HP-UX IPF | 9.1 TS1M0 | |
Linux | 9.1 TS1M0 | |
OpenVMS Alpha | 9.1 TS1M0 | |
Tru64 UNIX | 9.1 TS1M0 | |