I have a dataset of USA customer zipcodes. I wanted to plot it on the USA map. I am using a code on SAS website 'Sample 31419: Place symbols at ZIP code locations on a U.S. map'
I am getting error in the proc gproject.
Please provide a solution to overcome the error.
748 /* Project the combined data set. */
749 proc gproject data=all out=allp;
750 id state;
NOTE: PARALLEL1 = -38.23542475.
NOTE: PARALLEL2 = 34.36803175.
ERROR: Standard parallels lie on opposite sides of the equator.
ERROR: Equator is too close to the median latitude of the map data set for default
parallel calculation. Try specifying PARALLEL1 and PARALLEL2 values
sashelp.zipcode(rename=(x=long y=lat)keep=x y zip);
keep zip x y;
if x eq . then delete;
/* Create an annotate data set to place a symbol at the
ZIP code locations. */
retain xsys ysys '2' function 'label' size .75 flag 1 when 'a';
/* Combine the map data set with the annotate data set. */
set maps.states(where=(state not in(2 15 72))) anno;
/* Project the combined data set. */
proc gproject data=all out=allp;
/* Separate the projected data set into a map and an annotate data set. */
data map dot;
if flag=1 then output dot;
else output map;
/* Define the pattern for the map. */
pattern1 v=me c=black r=50;
/* Define the title for the map. */
title 'Customer ZIP Code locations';
/* Generate the map and place the symbols at ZIP code locations. */
proc gmap data=map map=map;
choro state / anno=dot nolegend;
Similar to how you limit your map to just the 48 continental states, by eliminating Alaska, Hawaii, and Puerto Rico, using ... set maps.states(where=(state not in(2 15 72)))
You'll need to make sure your zipcode list only contains zipcodes from the continental US - if that condition is met, then (on a good day) you should not need any special gproject options to project your map and your zipcode lat/longs.
*But* there is one caveat ... in v9.2 the lat/long for 2 zipcodes in New Jersey was inadvertantly "reversed" in sashelp.zipcode, and therefore if you have a v9.2 sashelp.zipcode file then you'll also need to eliminate those two. Here's some code that does both of the above (pretending that sashelp.zipcode is your customer data)...
data temp; set sashelp.zipcode
'AL' 'AR' 'AZ' 'CA' 'CO' 'CT' 'DC' 'DE' 'FL' 'GA'
'IA' 'ID' 'IL' 'IN' 'KS' 'KY' 'LA' 'MA' 'MD' 'ME'
'MI' 'MN' 'MO' 'MS' 'MT' 'NC' 'ND' 'NE' 'NH' 'NJ'
'NM' 'NV' 'NY' 'OH' 'OK' 'OR' 'PA' 'RI' 'SC' 'SD'
'TN' 'TX' 'UT' 'VA' 'VT' 'WA' 'WI' 'WV' 'WY'
zip not in (08403, 08402)
You can download a new/fixed sashelp.zipcode from the SAS "Maps Online" website (I haven't tried that, so I'm not 100% sure), and also the problem is fixed in the upcoming v9.2m3 release of SAS. Here's a google search that'll help you find the SAS mapsonline page to download the new zipcode file that fixes the 2 bad NJ zipcodes:
I just deleted those two zipcodes and it worked. But I get some warning in proc gmap.
Can you tell me what the issue is.
023 proc gmap data=map map=map;
1024 id state;
1025 choro state / anno=dot nolegend;
WARNING: Some observations were discarded when charting STATE. Only first matching
observation was used. Use STATISTIC= option for summary statistics.
NOTE: PROBLEM IN OBSERVATION 1 -
DATA SYSTEM REQUESTED, BUT VALUE IS NOT ON GRAPH 'Y'
"WARNING: Some observations were discarded when charting STATE. Only first matching observation was used. Use STATISTIC= option for summary statistics."
Is no problem - since you had no response data to plot on the map areas, you just used the map= data set as the data= data set also, and since the map has multiple obsns for each map area, it just uses the first one as the 'response' value to plot. Really unimportant since we're making the map all one color, and not trying to show some data by the colors.
The 2nd message:
"NOTE: PROBLEM IN OBSERVATION 1 -
DATA SYSTEM REQUESTED, BUT VALUE IS NOT ON GRAPH 'Y' "
Might be more important - this is probably saying that the 1st obsn in your annotate data is outside of the X/Y range covered by the map. Did you make sure to limit your zipcodes to just the 48 contiguous states? If you had an Alaska zipcode and tried to annotate that onto a map of the 48 contiguous states, that could cause this message. Since it claims the problem is in "obsn 1", maybe scrutinize the first obsn in your annotate data. Sometimes annotate is a bit 'chatty', and just complains like this, when in actuality the annotate value is visible in the output, but technically "not on graph".
Do your results look the way you want/expect them? That's the main thing! :-)