Sample 25508: Using BY-Groups to make a series of charts using PROC GCHART
This sample is from the "SAS/GRAPH Software: Reference, Version 8", Volume 1, Chapter 8. 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: GBYGMSC1 |
| TITLE: GBYGMSC1-Using BY-groups to Make a Series of Charts |
| PRODUCT: GRAPH |
| SYSTEM: ALL |
| KEYS: GRAPHICS AXIS PATTERN GCHART |
| PROCS: GCHART |
| DATA: INTERNAL |
| |
| SUPPORT: GRAPHICS STAFF UPDATE: |
| REF: SAS/GRAPH REFERENCE GUIDE |
+--------------------------------------------------------------+*/
/* Set the graphics environment */
goptions reset=all gunit=pct border cback=white
colors=(black blue green red)
ftitle=swissb ftext=swiss htitle=5 htext=4
hsize=5in vsize=5in;
/* Add the data set GRAINLDR */
data grainldr;
length country $ 3 type $ 5;
input year country $ type $ amount;
megtons=amount/1000;
datalines;
1995 BRZ Wheat 1516
1995 BRZ Rice 11236
1995 BRZ Corn 36276
1995 CHN Wheat 102207
1995 CHN Rice 185226
1995 CHN Corn 112331
1995 IND Wheat 63007
1995 IND Rice 122372
1995 IND Corn 9800
1995 INS Wheat .
1995 INS Rice 49860
1995 INS Corn 8223
1995 USA Wheat 59494
1995 USA Rice 7888
1995 USA Corn 187300
1996 BRZ Wheat 3302
1996 BRZ Rice 10035
1996 BRZ Corn 31975
1996 CHN Wheat 109000
1996 CHN Rice 190100
1996 CHN Corn 119350
1996 IND Wheat 62620
1996 IND Rice 120012
1996 IND Corn 8660
1996 INS Wheat .
1996 INS Rice 51165
1996 INS Corn 8925
1996 USA Wheat 62099
1996 USA Rice 7771
1996 USA Corn 236064
;
/* Create a format for the values of COUNTRY */
proc format;
value $country 'BRZ' = 'Brazil'
'CHN' = 'China'
'IND' = 'India'
'INS' = 'Indonesia'
'USA' = 'United States';
run;
/* Suppress the default BY-line */
option nobyline;
/* Define title and footnote for chart */
title1 'Leading #byval(type) Producers' j=c '1995 and 1996';
footnote1 j=r h=3 'GBYGMSC1 ';
/* Define pattern characteristics */
pattern color=green;
/* Define response axis characteristics */
axis1 order=(0 to 550 by 100)
label=(angle=90 'Millions of Metric Tons')
major=none
minor=none
value=none
style=0
noplane;
/* Define midpoint axis characteristics */
axis2 label=none
split=' ';
/* Sort data set TOTALS in order by site */
proc sort data= grainldr out=temp;
by type;
run;
/* Generate vertical bar chart */
/* using GROUP=SITE */
proc gchart data=temp (where=(megtons gt 31));
by type;
format country $country.;
vbar3d country / sumvar=megtons
outside=sum
descending
shape=hexagon
width=8
coutline=black
cframe=grayaa
maxis=axis2
raxis=axis1;
run;
quit;
This example uses a BY statement with the GCHART procedure to produce a separate 3D vertical bar chart for each value of the BY variable TYPE.
| Type: | Sample |
| Topic: | Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Types ==> Charts ==> Bar SAS Reference ==> Procedures ==> GCHART
|
| Date Modified: | 2006-02-22 03:02:43 |
| Date Created: | 2005-05-23 14:12:08 |
Operating System and Release Information
| SAS System | SAS/GRAPH | All | 8 TS M0 | n/a |