Data visualization with SAS programming

Error with GPROJECT

Reply
Frequent Contributor
Posts: 99

Error with GPROJECT

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.
SAS Employee
Posts: 967

Re: Error with GPROJECT

The answer probably depends very much on what your "data=all" has in it.
Could you show the code you used to create that?
Frequent Contributor
Posts: 99

Re: Error with GPROJECT

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;
SAS Employee
Posts: 967

Re: Error with GPROJECT

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;
Frequent Contributor
Posts: 99

Re: Error with GPROJECT

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
SAS Employee
Posts: 967

Re: Error with GPROJECT

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
Frequent Contributor
Posts: 99

Re: Error with GPROJECT

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'
SAS Employee
Posts: 967

Re: Error with GPROJECT

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! :-)
Ask a Question
Discussion stats
  • 7 replies
  • 1152 views
  • 1 like
  • 2 in conversation