Sample 24895: Display 3D bars at cities on a state map
This example creates a "state" or map area for each of the three Florida cities by subsetting their coordinates from MAPS.USCITY
and assigning each city a unique identification value. These three
new map areas are then added to a map data set of Florida. The response data set also uses the new identification values so that the map of Florida can display data at the city locations.
/* The GMAP procedure draws only one block per state, the way */
/* to display blocks at city locations is to create an artificial */
/* "state" for each city and add the new "states" to a map data set. */
/* This example creates a "state" or map area for each of the three */
/* Florida cities by subsetting their coordinates from MAPS.USCITY */
/* and assigning each city a unique identification value. These three */
/* new map areas are then added to a map data set of Florida. The */
/* response data set also uses the new identification values so that */
/* the map of Florida can display data at the city locations. */
/* Set graphics options */
goptions reset=all;
goptions reset=global gunit=pct colors=(white) cback=blue
ftext=swiss htext=4;
/* Create the data set, CTYCOORD. CTYCOORD is a map data set of three */
/* Florida cities. It is created by subsetting MAPS.USCITY and */
/* assigning a unique value for each city to the variable STATE. */
data ctycoord(drop=cityfips);
set maps.uscity(where=(state=12 and cityfips in (1050,1510,2950))
keep=city cityfips state x y);
state=state+cityfips;
output;
/* Define a polygon for the GMAP procedure, add a small */
/* number to the X and Y to create a small triangle at each */
/* of the port locations. */
x=x+.0000001; output;
y=y+.0000001; output;
run;
/* Create the map data set, FLMAP. FLMAP contains map coordinates and */
/* identification values for both Florida and the three cities. The SET */
/* statement uses the WHERE= data set options to subset map information */
/* for Florida (FIPS code 12) and then appends the observations in the */
/* CTYCOORD data set to create FLMAP. */
data flmap;
set maps.us(where=(state=12) drop=segment) ctycoord;
run;
/* Create the response data, SHIPPING. SHIPPING contains the number of tons */
/* shipped from the three Florida ports. The variable STATE is assigned the */
/* same unique identification value as in the CTYCOORD data set. */
data shipping(drop=cityfips);
input state cityfips portname & $15. tonnage;
state=state+cityfips;
datalines;
12 2950 Tampa Harbor 49280790
12 1510 Jacksonville 15002231
12 1050 Port Everglades 14684674
12 0 . .
;
/* Create the Annotate data set, LABEL. LABEL adds the names of the cities */
/* to the map. Because block maps cannot use data coordinate systems, the */
/* labels are positioned using coordinate system 3 (absolute percent of the */
/* graphics output area) and explicitly assigning coordinate values to the */
/* X and Y variables. */
data label;
length function $ 8 text $ 20;
retain function 'label' xsys ysys hsys '3' size 3;
position='4'; /* POSITION='4' right aligns the label */
x=77; y=70; text='Jacksonville'; output;
position='6'; /* POSITION='6' left aligns the labels */
x=35; y=50; text='Tampa Harbor'; output;
x=86; y=27; text='Port'; output;
x=86; y=23; text='Everglades'; output;
run;
/* Add titles and footnotes. The null FOOTNOTE1 statement adds space for the */
/* city labels to the right of the map. FOOTNOTE2 adds space to the left of */
/* the map. */
title1 height=5 'Commerce at Florida Ports';
title2 '(1991)';
footnote1 angle=90 height=15 ' ';
footnote2 angle=-90 height=2 ' ';
footnote3 height=2.5 font=swissl justify=left ' SAS/GRAPH' move=(+0,+.5)
'02'x move=(+0,-.5) ' Software' justify=right 'COMMERCE ';
/* Define patterns for the map. PATTERN1 specifies a color for the map areas. */
/* The remaining PATTERN statements specify colors for the blocks. */
pattern1 value=msolid color=lime;
pattern2 value=solid color=vioy;
pattern3 value=solid color=orange;
pattern4 value=solid color=maroon;
/* Modify the legend. MODE=SHARE allows the legend to be drawn with the map in */
/* the procedure output area. */
legend1 shape=bar(6,3) position=(left bottom) offset=(5,8)
mode=share across=1 label=(position=top 'Tons Shipped');
/* Produce the block map of Florida. Both the map data set, FLMAP, and the response */
/* data set, SHIPPING, include the same ID variable, STATE. The DISCRETE option in */
/* the BLOCK statement causes each value of TONNAGE to be a separate response level. */
/* The BLOCK statement includes the annotation defined in the LABEL data set. */
proc gmap data=shipping map=flmap;
format tonnage comma12.;
id state;
block tonnage / discrete blocksize=4 xview=.7 legend=legend1
annotate=label;
run;
quit;

The GMAP procedure draws only one block per state, the way to display blocks at city locations is to create an artificial "state" for each city and add the new "states" to a map data set.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> GMAP Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Types ==> Maps ==> Special Maps
|
| Date Modified: | 2005-08-24 16:06:30 |
| Date Created: | 2004-11-11 11:07:56 |
Operating System and Release Information
| SAS System | SAS/GRAPH | All | n/a | n/a |