/* You must specify a path for this variable */ %let path=path-to-your-web-server; /*---------------------------------------------* * PROC GBARLINE example for SAS/GRAPH 9.1.3 *---------------------------------------------*/ /*-------------------------------------------------------------* * Electricity production revenue by customer * Source: Energy Information Administration * http://www.eia.doe.gov/cneaf/electricity/epa/epat7p3.html *-------------------------------------------------------------*/ data revenue; format Revenue dollar8.; length Customer $ 14; input Year Revenue Customer; Revenue = Revenue/1000; /* Convert millions to billions */ datalines; 1994 84552 Residential 1994 63396 Commercial 1994 48069 Industrial 1994 6689 Other 1995 87610 Residential 1995 66365 Commercial 1995 47175 Industrial 1995 6567 Other 1996 90503 Residential 1996 67829 Commercial 1996 47536 Industrial 1996 6741 Other 1997 90704 Residential 1997 70497 Commercial 1997 47023 Industrial 1997 7110 Other 1998 93360 Residential 1998 72575 Commercial 1998 47050 Industrial 1998 6863 Other 1999 93483 Residential 1999 72771 Commercial 1999 46846 Industrial 1999 6796 Other 2000 98209 Residential 2000 78405 Commercial 2000 49369 Industrial 2000 7179 Other 2001 103158 Residential 2001 85741 Commercial 2001 50293 Industrial 2001 8151 Other 2002 106834 Residential 2002 87117 Commercial 2002 48336 Industrial 2002 7124 Other 2003 111249 Residential 2003 96263 Commercial 2003 51741 Industrial 2003 514 Other 2004 115577 Residential 2004 100546 Commercial 2004 53477 Industrial 2004 519 Other 2005 128393 Residential 2005 110522 Commercial 2005 58445 Industrial 2005 643 Other ; run; proc summary; var revenue; class Year; output out=revenue sum=revenue; run; data revenue; set revenue (drop=_type_ _freq_); if Year; run; /*--------------------------------------------------------------* * Energy generation in thousand megawatthours * Source: Energy Information Administration * http://www.eia.doe.gov/cneaf/electricity/epa/epat1p1.html *--------------------------------------------------------------*/ data generated; format Power comma10.; label Power = 'Electricity Generation in thousand megawatt-hours'; input Year Power; datalines; 1994 3247522 1995 3353487 1996 3444188 1997 3492172 1998 3620295 1999 3694810 2000 3802105 2001 3736644 2002 3858452 2003 3883185 2004 3970555 2005 4054688 ; run; /*-------------------------------------------* * Combine the revenue and generation data *-------------------------------------------*/ data combined; merge generated revenue; by year; label Revenue = 'Revenue (billions)' Power = 'Electricity Generation in thousand megawatt-hours'; length barhtml $ 200; /* Define URL link and popup tool tip text for BARs */ barhtml = 'href=http://www.eia.doe.gov/fuelelectric.html ' || 'title=' || quote( 'Year: ' || trim(left(Year)) || '0d'x || 'Bar: ' || trim(left(put(Revenue, dollar10.))) || ' (billion) revenue' || '0d'x || 'Line: ' || trim(left(put(Power, comma12.))) || ' GWh power' ) || ' '; run; /*-------------------------------------* * Create combination bar/plot chart *-------------------------------------*/ ods html close; /* Output location and filename and ODS style */ ods html path="&path" file="US_Electric_Power_(9.1.3).htm"; /* Graphic options */ goption reset=all device=gif gunit=pct xmax=9in ymax=8in ftitle='arial/bold' ftext='arial/bold' htitle=3.5 htext=2 cback=white csymbol=black border; /* Chart title and footnotes */ title1 ls=1.5 "US Electric Power - Revenue and Generation"; title2 " "; footnote1 j=l f=zapf " Data: US Energy Information Administration"; footnote2 j=l f=zapf " GWh: gigawatt-hours or thousand megawatt-hours"; footnote3 j=l f=zapf " Note: Created with GBARLINE Procedure (SAS/GRAPH 9.1.3)"; footnote4 " "; /* Left, right and bottom axes */ axis1 label=(j=c h=2.5 c=CX806A2B font='arial/bold' "Revenue" j=c "(bars in billions)") minor=none offset=(,5 pct); axis2 label=(j=c h=2.5 font='arial/bold' c=styg "Power" j=c "Generated" j=c "(line plot in GWh)") minor=none; axis3 label=none offset=(3,3 pct); /* Line plot graphic parameters */ symbol1 v=dot h=1 c=styg w=2; pattern1 c=CX806A2B v=solid; /* Draw the chart */ proc gbarline data=combined; bar year / sumvar=Revenue discrete width=4 space=6 raxis=axis1 maxis=axis3 name='power913' coutline=gray html=barhtml; plot / sumvar=Power axis=axis2; run; quit; ods html close;