Hi everyone,
I'm working on a map that overlays the 2010 Core Based Statistical Areas (CBSAs) with the US county boundaries. I've imported the CBSA shapefiles from the US Census websites and am trying to combine it with the SAS supplied maps.counties dataset.
However, when I combine the two I get an error message that says "data system requrested, but value is not on graph 'X', 'Y'. I'm a bit confused about what I have done wrong. When I run proc gmap without the maps.counties overlay. I get the CBSA boundaries.
Below is a sample of my code.
Thanks!
/*Importing ESRI file*/
proc mapimport datafile=usdata out=cbsa10;run;
/*restricting CBSA boundaries to continental US*/
data cbsa10b;
set cbsa10;
state=SUBSTR(NAME10,LENGTH(NAME10)-1,2);
if state in ("AK","HI","PR") then delete;
run;
option mprint;
data anno_county; set maps.counties (where=(state not in (02,15,72)));
length function color $8;
anno_flag=1;
xsys='2'; ysys='2'; hsys='3'; when='a';
color='cx00ff00'; size=2.0;
if _n_=1 then function='poly';
else function='polycont';
run;
data combined;
set cbsa10b (drop=state) anno_county;
run;
data cbsa10b anno_county; set combined;
if anno_flag=1 then output anno_county;
else output cbsa10b;
run;
data mydata2;
set mydata;
if ST in ("AK","HI","PR") then delete;
run;
proc gmap all data=mydata2 map=cbsa10b all anno=anno_county;
id CBSAFP10;
choro myvariable / discrete coutline=black;
run;
quit;
This might also provide some helpful information:
http://robslink.com/SAS/book2/Chapter_07_Annotating_on_Maps.pdf
The SAS-supplied maps.counties x/y coordinates are in westlong radians.
What type of coordinates are the x/y variables in your map?
In order to overlay the maps.counties borders using annotate, the x/y of the map & annotate need to be using the same coordinate system.
Hi Rob,
Thanks for your reply. You are right. My coordinates were not westlong radians. From some of your previous codes, I found the conversation formula and converted the coordinates from the CBSA map. I then combined the dataset and added a project gproject step. However, the county boundaries aren't showing up on my map - only the CBSA boundaries.
I will review the annotate link you sent and see if that helps with why the county boundaries are not showing up.
Thanks.
It might be useful to use Proc Gplot to plot the x/y of your map, and then use it to plot the x/y of your annotate dataset ... I suspect you will see that they cover different ranges of values, and have no overlap (this is why the annotate is not showing up). Gmap will only show you the range of values that the map occupies (if the annotate has x/y coordinates outside of the map's x/y range, then the annotate will not show up).
Hi Rob,
Sorry to bother you again - but now I have another question. All in all my map looks great thanks to your help. However, I noticed that my boundaries are slightly off. Perhaps its from the X/Y coordinates supplied in the CBSA shape files? Any suggestions on how to line things up better? Attached is my current working version of the maps.
Thanks!
Sophia
My best guess would be that the map and the annotated borders weren't projected exactly the same.
Hi Rob,
Thanks for your help! I know think I have a working version of my map! Really appreciate your time and especially the document you sent.
This might also provide some helpful information:
http://robslink.com/SAS/book2/Chapter_07_Annotating_on_Maps.pdf
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.