Sample 24905: Combine United States and Canadian Province
/***************************************************************/
/* The following sample will create a map of Canada and the US */
/* showing the number of NHL teams in each province or state */
/***************************************************************/
/* Set graphics options */
goptions reset=all rotate=landscape border;
/* Create the input data set, CANTEAMS for the number of */
/* teams in each Canadian province. */
data canteams;
input province $2. teams;
datalines;
24 2 /* Quebec */
35 2 /* Ontario */
46 1 /* Manitoba */
48 2 /* Alberta */
59 1 /* British Columbia */
;
/* Create the input data set, USTEAMS for the number of */
/* teams in each US state. */
data usteams;
input staten $2. teams;
datalines;
CA 3
CT 1
DC 1
FL 2
IL 1
MA 1
MI 1
MO 1
NJ 1
NY 2
PA 2
TX 1
;
/* Create the input data set, ALLTEAMS, from */
/* the two response data sets. */
/* Since we need one identification variable, */
/* we need to put the province and the state */
/* values into one variable, STATEN. The */
/* state postal codes are used for the US */
/* instead of the FIPS codes so they won't */
/* interfere with the province codes. */
data allteams;
/* Rename the PROVINCE variable to be STATEN */
set canteams(rename=(province=staten)) usteams;
run;
/* Create the input data set, MAPALL, by */
/* combining the CANADA4 and STATES map data sets.*/
/* Create a common identification variable for */
/* the combined map data set from the province */
/* code and the state code. */
data mapall(drop=state province);
set maps.canada4(in=incan)
maps.states(where=(state not in(15 72))); /* Remove Hawaii and Puerto Rico */
/* Assign the province code */
if incan then staten=province;
/* Assign the state postal code to the ID variable */
else staten=fipstate(state);
run;
/* Project the combined map using the Gnomonic projection with the */
/* POLELONG= option to center the new map near the middle of */
/* the United States and Canada. */
proc gproject data=mapall out=projmap project=gnomon polelong=100;
id staten;
run;
quit;
/* Define patterns for the map */
pattern1 v=ms c=blue;
pattern2 v=ms c=green;
pattern3 v=ms c=red;
/* Add the title and footnotes */
title1 f=swissb 'NHL TEAMS';
title2 f=swiss 'BY PROVINCE AND STATE';
footnote1 '1994 Data';
/* Modify the appearance of the legend */
legend1 label=('Number of Teams:') down=1;
/* Generate a map of Canada and the US showing NHL teams */
proc gmap data=allteams map=projmap all;
id staten;
choro teams / discrete coutline=black legend=legend1;
run;
quit;

This sample program creates a map of Canada and the US.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> GMAP Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Types ==> Maps ==> Map boundaries
|
| Date Modified: | 2006-08-24 03:02:52 |
| Date Created: | 2004-11-11 11:07:58 |
Operating System and Release Information
| SAS System | SAS/GRAPH | All | n/a | n/a |