The following examples illustrate major features of the GPROJECT procedure. Because these examples use map data sets that are supplied with SAS/GRAPH , you may need to replace SAS-data-library in the LIBNAME statement with the actual location of the SAS data library that contains the Institute-supplied map data sets on your system. Contact your SAS Software Consultant for the location of the map data sets at your site. If your site automatically assigns the libref MAPS to the SAS data library that contains the Institute-supplied map data sets, delete the LIBNAME statement in these examples.
Procedure features:
ID statement
Other features:
LIBNAME statement
Sample library member: GPJDEFLT
This example demonstrates the effect of using PROC GPROJECT on an unprojected map data set without specifying any options. Because PROJECT= is not used in the PROC GPROJECT statement, the Albers equal-area projection method is used by default. PROC GPROJECT supplies defaults for the standard parallels that minimize distortion of the projected map areas.
Figure 39.8 on page 1174 illustrates the output produced the US48 map data set, which contains only unprojected values, X and Y. Output 39.1 shows the variables in the data set.
US48 Data Set OBS STATE SEGMENT DENSITY X Y 1 1 1 3 1.48221 0.56286 2 1 1 3 1.48226 0.56234 3 1 1 3 1.48304 0.56231 . . .
The GPROJECT procedure is used with the US48 map data set as input to create the projected map data set, US48PROJ. The values for X and Y in this new data set are projected (cartesian). Output 39.2 shows the variables in the data set.
US48PROJ Data Set OBS X Y DENSITY STATE SEGMENT 1 0.16068 -0.073470 3 1 1 2 0.16069 -0.073993 3 1 1 3 0.16004 -0.074097 3 1 1 . . .
The new projected map data set, US48PROJ, is used to create the projected map, Figure 39.9 on page 1175.
Assign the libref and set the graphics environment.
libname maps 'SAS-data-library'; goptions reset=global gunit=pct border cback=white colors=(black blue green red) ftext=swiss htitle=6 htext=3;
Create reduced continental U.S. map data set and remove Alaska, Hawaii, and Puerto Rico.
data us48; set maps.states; if state ne 2 and state ne 15 and state ne 72; if density<4; run;
Define title and footnote for unprojected map.
title 'United States Map'; footnote j=r 'GPJDEFLT(a) ';
Define pattern characteristics.
pattern value=mempty repeat=50 color=blue;
Show unprojected map.
proc gmap map=us48 data=us48 all; id state; choro state / nolegend; run;
Project map data set using all default criteria. The ID statement identifies the variable in the input map data set that defines unit areas.
proc gproject data=us48 out=us48proj; id state; run;
Define footnote for projected map.
footnote j=r 'GPJDEFLT(b) ';
Show projected map.
proc gmap map=us48proj data=us48proj all; id state; choro state / nolegend; run; quit;
Procedure features:
PROC GPROJECT options:
POLELAT=
POLELONG=
PROJECT=
Sample library member: GPJEMPHS
This example uses the gnomonic projection method to create a map in which the east coast of the United States appears disproportionately large compared to the west coast .
Assign the libref and set the graphics environment.
libname maps 'SAS-data-library'; goptions reset=global gunit=pct border cback=white colors=(black blue green red) ftext=swiss htitle=6 htext=3;
Create reduced continental U.S. map data set and remove Alaska, Hawaii, and Puerto Rico.
data us48; set maps.states;
if state ne 2 and state ne 15 and state ne 72; if density<4; run;
Project map onto a plane centered in the Pacific. PROJECT= specifies the projection method for the map data set. POLELONG= and POLELAT= specify a projection pole for the gnomonic projection. In this example, the pole is positioned in the Pacific Ocean.
proc gproject data=us48 out=skew project=gnomon polelong=160 polelat=45; id state; run;
Define title and footnote for the map.
title 'United States Map'; footnote j=r 'GPJEMPHS ';
Define pattern characteristics.
pattern value=mempty repeat=49 color=blue;
Show the projected map.
proc gmap map=skew data=skew all; id state; choro state / nolegend; run; quit;
Procedure features:
PROC GPROJECT options:
LONGMAX=
LONGMIN=
LATMAX=
LATMIN=
Sample library member: GPJCLIPP
This example uses the clipping capabilities of PROC GPROJECT to create a map of the states in the United States that border the Gulf of Mexico. Because the PROJECT= option is not used in the GPROJECT procedure, the Albers equal-area projection method is used by default.
Assign the librefs and set the graphics environment.
libname maps 'SAS-data-library'; goptions reset=global gunit=pct border cback=white colors=(black blue green red) ftext=swiss htitle=6 htext=3;
Clip and project rectangular subset of the map. LONGMIN= and LONGMAX= specify the minimum and maximum longitudes to be included in the map projection. LATMIN= and LATMAX= specify the minimum and maximum latitudes to be included in the map projection.
proc gproject data=maps.states out=gulf longmin=81 longmax=98 latmin=25 latmax=33; where density<5; id state; run;
Define title and footnote for the map.
title 'Northern Gulf Coast'; footnote j=r 'GPJCLIPP ';
Define pattern characteristics.
pattern value=mempty repeat=7 color=blue;
Show the clipped map.
proc gmap map=gulf data=gulf all; id state; choro state / nolegend; run; quit;
Procedure features:
PROC GPROJECT options:
DATA =
OUT=
ID statement
Other features:
CHORO statement
Annotate data set
Sample library member: GPJANNOT
This example illustrates how to project an Annotate data set for use with a map data set. It labels the locations of Miami, Boston, and Bangor on the map shown in the second example. Because the X and Y variables in the USCITY data set already have been projected to match the US data set, they cannot be used with the map that is produced by the second example. To properly label the projected map, the example uses the same projection method for the city coordinates as the method that is used for the map coordinates. This example illustrates how to use the same projection method for both data sets.
Assign the librefs and set the graphics environment.
libname maps 'SAS-data-library'; goptions reset=global gunit=pct border cback=white colors=(black blue green red) ftext=swiss htitle=6 htext=3;
Create reduced continental U.S. map data set and remove Alaska, Hawaii, and Puerto Rico.
data us48; set maps.states; if state ne 2 and state ne 15 and state ne 72; if density<4; run;
Create Annotate data set CITIES from the MAPS.USCITY data set. The unprojected LONG and LAT variable values are converted to radians and substituted for the projected X and Y variable values. LONG and LAT are converted by multiplying them by the arccosine of ˆ’ 1 and dividing that amount by 180. The cities are each assigned a value for the NEWST variable, sequentially beginning at 100.
data cities(drop=state rename=(newst=state)); set maps.uscity(keep=lat long city state); length function style color $ 8 position $ 1 text $ 20; retain function 'label' xsys ysys '2' hsys '1' when 'b' newst 100; if state=12 and city='Miami' or state=25 and city='Boston' or state=23 and city='Bangor'; newst+1; color='blue'; size=10; text='T'; position='5'; style='marker'; x=long*arcos(-1)/180; y=lat*arcos(-1)/180; output; newst+1; color='blue'; size=4; text=' 'city; position='6'; style='swissb'; output; run;
Create data set ALL by combining data set US48 and data set CITIES.
data all; set us48 cities; run;
Project the ALL data set. DATA= specifies the data set to be projected. OUT= specifies the name of the new projected data set that is created. The ID statement identifies the variable in the input map data set that defines map areas.
proc gproject data=all out=allp project=gnomon polelong=160 polelat=45; id state; run;
Separate the projected data set into the CITIESP Annotate data set and the US48P map data set.
data citiesp us48p; set allp; if state>100 then output citiesp; else output us48p; run;
Define title and footnote for the map.
title1 'Distribution Center Locations'; title2 'East Coast'; footnote j=r 'GPJANNOT ';
Define pattern characteristics.
pattern value=mempty repeat=49 color=blue;
Show the annotated map. The CHORO statement displays the projected map and annotates it using the projected Annotate data set.
proc gmap data=us48p map=us48p all; id state; choro state / nolegend annotate=citiesp; run; quit;