SAS.GRAPH 9.1 Reference, Volumes I and II

Embedding ActiveX Graphs in Word Files

The following example demonstrates how the ODS RTF statement can be combined with the ACTIVEX device driver to generate interactive graphics inside Microsoft Word files. The example also shows how user -defined formats can be used to enhance the appearance of graph labels and the headings of PROC PRINT tabular output.

The following example is available in the SAS Sample library under the name GWBAXRTF.

ods rtf file=c:\Public\graph.1\gwbaxrtf.rtf style=torn; goptions dev=activex; PROC FORMAT; value agefmt 0-10=0 to 10 11-12=Pre-Teen 13-15=Mid-Teen 16=late-Teen; value $sexfmt m=Male f=Female; value weightfmt 0-99.9=0-99 lbs 100-119=100-119 lbs 120-149=120-149 lbs 150-999=150 lbs or more; run; data class; set sashelp.class; format age agefmt. sex $sexfmt. weight weightfmt.; label sex=Gender; label height=Average Height (inches); input name sex age height weight; datalines; Alfred m 14 69 112.5 Barbara f 13 65.3 98 Henry m 14 63.5 102.5 Jane f 12 59.8 84.5 John m 12 59 99.5 Joyce f 11 51.3 50.5 Mary f 15 66.5 112 Philip m 16 72 150 Robert m 12 64.8 128 Susan f 11 57.5 85 William m 15 66.5 112 ; run; Title "RTF Output with ActiveX Control"; Title2 "Physical Statistics"; proc gchart data=class; hbar weight / sumvar=height type=mean group=sex discrete; run; quit; Title2 "Formatted Classroom Data"; Proc print data=class; id name; run; ods rtf close;

Generating an Interactive Contour Plot in ActiveX

The following example displays a contour plot of water depth on a small island known as an atoll . The ActiveX Control lets you manipulate many of the aspects of the plot using the menu that is displayed with the right mouse button.

Of note in this example is the way that PROC G3GRID is used to generate a rectangular grid of points.

This example, including the full data set, is available in the SAS Sample Library under the name GWBAXCON.

ods html file="your_web_path/your_HTML_file.htm"; goptions device=activex xpixels=500 ypixels=350 border cback=white gunit=pct htext=3; data atoll; input vdist hdist depth; datalines; 10 0.25 2.77 20 0.25 2.77 30 0.25 2.77 40 0.25 2.77 50 0.25 2.77 60 0.25 2.77 70 0.25 2.77 80 0.25 2.77 90 0.25 2.77 100 0.25 2.77 /* for the full data set, see GWBAXCON */ 62 133.75 5.00 64 135 5.00 64 136.25 5.00 60 138.75 5.08 62 138.75 5.08 ; run; /* Prepare the data to be a rectangular grid */ /* of points. */ proc g3grid data=atoll out=atollgrid; grid vdist*hdist=depth / naxis1=50 naxis2=50; run; title 'Pacific Atoll'; axis1 order=(0 to 150 by 25) c=cx002288 width=3 minor=(n=4) label=('Meters'); axis2 order=(0to 100 by 25) c=cx002288 width=3 minor=(n=4) label=('Meters'); legend1 frame label=(position=top j=c 'Depth (in meters)') shape=line(7); proc gcontour data=atollgrid; plot vdist*hdist=depth / levels = 1 2 2.5 3 3.5 4 4.5 5 7 9 clevels = CXFF0000 CXF07275 CXEC9592 CXE9A2B2 CXE5BFC6 CXBFA0CF CX9981D8 CX7362E1 CX4D43EA CX0000FF legend=legend1 haxis=axis1 vaxis=axis2 des='Atoll'; run; quit;

Категории