BookmarkSubscribeRSS Feed
AmitKB
Fluorite | Level 6
Hi everyone,
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.

Thanks,

Amit

Error:

748 /* Project the combined data set. */
749 proc gproject data=all out=allp;
750 id state;
751 run;

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
explicitly.
7 REPLIES 7
GraphGuy
Meteorite | Level 14
The answer probably depends very much on what your "data=all" has in it.
Could you show the code you used to create that?
AmitKB
Fluorite | Level 6
Hi Rob,
This is the entire code:

Thanks,

Amit

* Temp contains customer zip;

proc sort data=temp nodupkey;
by zip;
run;

data longlat;
merge temp(in=mine)
sashelp.zipcode(rename=(x=long y=lat)keep=x y zip);
by zip;
if mine;
x=atan(1)/45*long;
y=atan(1)/45*lat;
x=-x;
keep zip x y;
if x eq . then delete;
run;

/* Create an annotate data set to place a symbol at the
ZIP code locations. */
data anno;
set longlat;
retain xsys ysys '2' function 'label' size .75 flag 1 when 'a';
style='special';
text='M';
color='red';
output;
run;

/* Combine the map data set with the annotate data set. */
data all;
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 flag=1 then output dot;
else output map;
run;

/* 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;
id state;
choro state / anno=dot nolegend;
run;
quit;
GraphGuy
Meteorite | Level 14
Can also provide an example of a zipcode that the above code fails on?

I tried it with the following zipcode (for Cary, NC), and it works ok with that one...

data temp;
zip=27513; output;
run;
AmitKB
Fluorite | Level 6
Hi Rob,
There are more than a million data points. The error happens at the proc gproject. How can I isolate the problem zip codes.
Does proc gproject has a way to output error records.

Thanks,

Amit
GraphGuy
Meteorite | Level 14
Ok - here's my theory ...

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
(where=(
zipstate(zip) in
(
'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'
)
and
zip not in (08403, 08402)
));
run;

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:

http://www.google.com/search?&q=08403&as_sitesearch=support.sas.com

Or, you could also manually fix the 2 zipcodes' lat/long in the sashelp.zipcode file, by manually switching the x/y values for those 2 zipcodes:

ZIP Y X

08403 -74.537153 39.315216
08402 -74.506230 39.330254
AmitKB
Fluorite | Level 6
Hi Rob,
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.

Thanks,

Amit


023 proc gmap data=map map=map;
1024 id state;
1025 choro state / anno=dot nolegend;
1026 run;

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'
GraphGuy
Meteorite | Level 14
This message:

"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! 🙂

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 2837 views
  • 2 likes
  • 2 in conversation