Maps Online web site." />
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
The graphics output in the Results tab was produced using SAS® 9.2. Submitting the sample code with releases of SAS prior to SAS 9.2 might produce different results.
/* Set the graphics environment */
goptions reset=all cback=white border htitle=12pt htext=10pt;
/* Create a data set containing ZIP codes. */
data myzip;
input Zip;
cards;
35004
85003
71601
80002
6001
19701
20001
32007
83201
60001
46001
50001
66002
40003
70001
3901
20601
1001
27513
;
run;
/* Sort the data set by ZIP codes. */
proc sort data=myzip;
by zip;
run;
/* Create a data set containing the */
/* X and Y values for my ZIP codes. */
data longlat;
/* In case there are duplicate ZIP codes, rename
X and Y from the SASHELP.ZIPCODE data set. */
merge myzip(in=mine)
sashelp.zipcode(rename=(x=long y=lat)keep=x y zip);
by zip;
/* Keep if the ZIP code was in my data set. */
if mine;
/* Convert longitude, latitude in degrees to radians */
/* to match the values in the map data set. */
x=atan(1)/45*long;
y=atan(1)/45*lat;
/* Adjust the hemisphere */
x=-x;
/* Keep only the ZIP, X and Y variables */
keep zip x y;
run;
/* Create an annotate data set to place a symbol at the */
/* ZIP code locations. */
data anno;
/* Use the X and Y values from the LONGLAT data set. */
set longlat;
/* Set the data value coordinate system. */
/* Set the function to label. */
/* Set the size of the symbol to .75. */
/* Set a FLAG variable to signal annotate observations. */
retain xsys ysys '2' function 'label' size 1.3 flag 1 when 'a';
/* Set the font to the Special font. */
style='special';
/* The symbol is a star. */
text='M';
/* Specify the color for the symbol. */
color='depk';
/* Output the observation to place the symbol. */
output;
run;
/* Combine the map data set with the annotate data set. */
data all;
/* Subset out the states that you do not want. */
/* The FIPS code of 2 is Alaska, 15 is Hawaii, */
/* and 72 is Puerto Rico. */
set maps.states(where=(state not in(2 15 72))) anno;
run;
/* Project the combined data set. */
proc gproject data=all out=allp;
id state;
run;
quit;
/* Separate the projected data set into a map and an annotate data set. */
data map dot;
set allp;
/* If the FLAG variable has a value of 1, it is an annotate */
/* observation; otherwise, it is a map data set observation. */
if flag=1 then output dot;
else output map;
run;
/* Define the pattern for the map. */
pattern1 v=me c=grp r=50;
/* Define the title for the map. */
title1 'ZIP Code locations on a US Map';
/* Generate the map and place the symbols at ZIP code locations. */
proc gmap data=map map=map;
id state;
choro state / anno=dot nolegend;
run;
quit;
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> GMAP Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Elements ==> Annotation |
Date Modified: | 2008-03-18 11:15:39 |
Date Created: | 2008-03-10 15:04:54 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | SAS/GRAPH | Solaris for x64 | ||
Linux for x64 | ||||
Linux on Itanium | ||||
OpenVMS Alpha | ||||
OpenVMS on HP Integrity | ||||
Solaris | ||||
Microsoft® Windows® for 64-Bit Itanium-based Systems | ||||
OpenVMS VAX | ||||
z/OS | ||||
Tru64 UNIX | ||||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | ||||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | ||||
Microsoft Windows Server 2003 Enterprise Edition | ||||
Microsoft Windows Server 2003 Datacenter Edition | ||||
Microsoft Windows NT Workstation | ||||
Microsoft Windows 2000 Professional | ||||
Microsoft Windows 2000 Server | ||||
Microsoft Windows 2000 Datacenter Server | ||||
Microsoft Windows 2000 Advanced Server | ||||
Microsoft Windows 95/98 | ||||
OS/2 | ||||
Microsoft® Windows® for x64 | ||||
Microsoft Windows XP 64-bit Edition | ||||
Microsoft Windows Server 2003 Standard Edition | ||||
Microsoft Windows XP Professional | ||||
Windows Millennium Edition (Me) | ||||
Windows Vista | ||||
64-bit Enabled AIX | ||||
64-bit Enabled HP-UX | ||||
64-bit Enabled Solaris | ||||
Linux | ||||
ABI+ for Intel Architecture | ||||
AIX | ||||
HP-UX | ||||
HP-UX IPF | ||||
IRIX |