Chapter Contents |
Previous |
Next |
SAS/GRAPH Software: Reference |
ODS HTML statement options:
| |||||||||||
GOPTIONS statement options:
| |||||||||||
LEGEND statement options:
| |||||||||||
WHERE statement |
Sample library member: GR08N08
Displaying a Map in a Web Page
This example illustrates the simplest way to use the ODS HTML statement to create an HTML file and a GIF file that you can display in a Web browser. It generates one body file that displays one piece of SAS/GRAPH output -- a map of average per capita income for four states.
This example also illustrates default pattern behavior with maps and explicit placement of the legend on the graph. It shows how the default solid map pattern rotates through every color in a colors list defined in the GOPTIONS statement. By default, the outline color is the first color in the list, in this case, BLACK.
And it shows how to use a LEGEND statement to arrange and position a legend so it fits well with the graph's layout.
Assign the libref and the Web-server path. FILENAME assigns the fileref ODSOUT, which is a destination for the HTML and GIF files produced by the example program. To assign that location as the HTML destination for program output, ODSOUT is specified later in the program on the ODS HTML statement's PATH= option. ODSOUT must point to a Web-server location if procedure output is to be viewed on the Web.
libname maps 'SAS-MAPS-library'; filename odsout 'path-to-Web-server-space';
Close the ODS Listing destination for procedure output, and set the graphics environment. To conserve system resources, ODS LISTING CLOSE closes the Listing destination for procedure output. Thus, the graphics output is not displayed in the GRAPH window, although it is written to the graphics catalog and to the GIF files. COLORS= on the GOPTIONS statement defines a list of four colors for the graph.
ods listing close; goptions reset=global gunit=pct cback=white colors=(black blue green red) ftext=swiss ftitle=swissb htitle=6 htext=4;
Create the data set INCOME. INCOME contains state codes for four states and the average income of each state.
data income; input state income; datalines; 04 19001 35 17106 40 17744 48 19857 ;
Assign graphics options for producing the ODS HTML output. DEVICE=GIF causes the ODS HTML statement to generate the graphics output as GIF files. TRANSPARENCY causes the graphics output to use the Web-page background as the background of the graph. Because the default setting NOBORDER is used, the edge of the graph is not visible on the Web page.
goptions device=gif transparency noborder;
Open the ODS HTML destination. BODY= names the file for storing HTML output. PATH= specifies the ODSOUT fileref as the destination for all the HTML and GIF files.
ods html body='income_body.html' path=odsout;
Define titles and a footnote for the map. By default, any defined titles and footnotes are included in the graphics output (GIF file).
title '1994 Personal Income Per Capita'; title2 f=swissb '(Arizona, New Mexico, Texas, and Oklahoma)'; footnote1 h=3 j=r 'GMAP ';
Define legend characteristics. ACROSS= defines the number of columns in the legend. ORIGIN= specifies an exact location for the legend. MODE= allows the legend to share the output area. LABEL= specifies a legend label and left-justifies it above the legend values. SHAPE= specifies a size and shape for the legend values.
legend across=2 origin=(10,20) mode=share label=(position=top justify=left 'Average Income') shape=bar(4,4);
Generate the prism map. Because the NAME= option is omitted, SAS/GRAPH assigns the default name GMAP to the GRSEG entry in the graphics catalog. This is the name that is assigned to the GIF file created by the ODS HTML statement.
proc gmap map=maps.us data=income; format income dollar6.0; id state; prism income / discrete legend=legend; run; quit;
Close the ODS HTML destination, and open the ODS Listing destination. You must close the HTML destination before you can view the output with a browser. ODS LISTING opens the Listing destination so that the destination is again available for displaying output during this SAS session.
ods html close; ods listing;
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.