Sample 25393: Embedded graphs with PROC REPORT and the ODS HTML statement
The sample code on the
Full Code tab uses the REPORT procedure, SAS/GRAPH®, and the ODS HTML statement to create report output for the web with embedded graphs.
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 sample uses PROC REPORT, SAS/GRAPH, and the ODS HTML statement to create report output for the web with embedded graphs. The GRSEG attribute in a CALL DEFINE statement is used and is valid in HTML and RTF destinations to include the graph in the report output. GRSEG is an undocumented attribute in PROC REPORT and is not supported in the ODS PDF destination.
The graphics output on the Results tab was produced using SAS® 9.2. Submitting the sample code with releases of SAS® prior to SAS 9.2 might produce different results.
options ps=100;
data budget;
input QTR @8 DEPT $10. @22 ACCOUNT $8. BUDGET ACTUAL;
attrib actual format=dollar11.2
budget format=dollar11.2
dept format=$10.;
datalines;
1 Staff fulltime 130000.00 127642.68
2 Staff fulltime 165000.00 166345.75
1 Staff parttime 40000.00 43850.12
2 Staff parttime 60000.00 56018.96
1 Equipment lease 40000.00 40000.00
2 Equipment lease 40000.00 40000.00
1 Equipment purchase 40000.00 48282.38
2 Equipment purchase 20000.00 17769.15
1 Equipment tape 8000.00 6829.42
2 Equipment tape 12000.00 11426.73
1 Equipment sets 7500.00 8342.68
2 Equipment sets 7500.00 8079.62
1 Equipment maint 10000.00 7542.13
2 Equipment maint 12000.00 10675.29
1 Equipment rental 4000.00 3998.87
2 Equipment rental 6000.00 5482.94
1 Facilities rent 24000.00 24000.00
2 Facilities rent 24000.00 24000.00
1 Facilities utils 5000.00 4223.29
2 Facilities utils 3500.00 3444.81
1 Facilities supplies 2750.00 2216.55
2 Facilities supplies 2750.00 2742.48
1 Travel leases 3500.00 3045.15
2 Travel leases 4500.00 3889.65
1 Travel gas 800.00 537.26
2 Travel gas 1200.00 984.93
1 Other advert 30000.00 32476.98
2 Other advert 30000.00 37325.64
1 Other talent 13500.00 12986.73
2 Other talent 19500.00 18424.64
1 Other musicfee 3000.00 2550.50
2 Other musicfee 5000.00 4875.95
;
run;
proc sort data=budget;
by qtr;
run;
proc format;
value forqtr 1='1st' 2='2nd';
run;
/* Set the graphics environment */
goptions reset=all cback=white border htitle=12pt htext=10pt;
goptions device=gif nodisplay xpixels=600 ypixels=400;
/* Create the graphics output */
proc gchart data=work.budget gout=work.gseg;
format dept $10.;
pie dept / discrete
sumvar=actual
percent=outside
value=outside
name='g25393'
;
by qtr;
run;
quit;
goptions display;
/* Close the listing destination */
ods listing close;
/* This sample writes its output to C:\TEMP */
/* when run on the Windows operating system. */
/* Modify the destination for the PATH= */
/* option below if you want to write the */
/* output to a location other than C:\TEMP */
/* or if you are running on an operating */
/* system other than Windows. */
/* Open the HTML destination */
ods html path="c:\temp" (url=none) file="g25393.html";
title1 'Graph Embedded in Report';
title2;
proc report data=work.budget nowd;
column qtr dept budget actual balance budget=bud2 actual=act2;
define qtr / group format=forqtr. width=12 'Quarter';
define dept / group format=$10. width=10 'Department';
define budget / sum noprint;
define actual / sum noprint;
define balance / computed format=dollar11.2 width=11 'Balance';
define bud2 / sum format=dollar11.2 width=11 'Budget';
define act2 / sum format=dollar11.2 width=11 'Actual'
style(COLUMN)=Header;
compute before _page_ /
style={background=CX0088EE foreground=black font_weight=bold};
/* Include graph in report output here */
if( qtr = 1 ) then
call define( _ROW_, "GRSEG", "work.gseg.g25393" );
else if (qtr = 2 ) then
call define( _ROW_, "GRSEG", "work.gseg.g253931" );
line 'Budget Information for ' qtr forqtr.
' Quarter by Department';
endcomp;
compute balance;
balance=budget.sum-actual.sum;
if dept ne ' ' then do;
if balance lt minbal then do;
minbal=balance;
mindept=dept;
minqtr=holdqtr;
end;
if balance lt qminbal then do;
qminbal=balance;
qmindept=dept;
end;
end;
if balance lt 0 then
call define( _COL_, "style", "style={background=pink}" );
endcomp;
break before qtr/ page;
compute before qtr;
holdqtr=qtr;
qminbal=0;
qmindept=' ';
endcomp;
break after qtr/;
compute after qtr;
length text3 text4 $ 72;
if qminbal=0 then do;
text3='No departments were over budget this quarter.';
text4=' ';
end;
else do;
text3='The largest overdraw for this quarter was in the '
|| trim(qmindept) || ' department.';
text4="It was overdrawn by " ||
trim(left(put(qminbal,dollar11.2)))||'.';
end;
line ' ';
line text3 $72.;
line text4 $72.;
line ' ';
endcomp;
rbreak before/;
compute before;
minbal=0;
mindept=' ';
endcomp;
rbreak after/;
run;
/* Close the HTML destination and */
/* open the Listing destination */
ods html close;
ods listing;
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 sample uses PROC REPORT, SAS/GRAPH®, and the ODS HTML statement to create report output for the web with embedded graphs.
| Type: | Sample |
| Topic: | Third Party ==> Output ==> HTML SAS Reference ==> Procedures ==> REPORT SAS Reference ==> ODS (Output Delivery System)
|
| Date Modified: | 2011-02-16 15:56:13 |
| Date Created: | 2005-05-23 13:50:50 |
Operating System and Release Information
| SAS System | Base SAS | All | 9.1 TS1M3 | n/a |