BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sophia_SAS
Obsidian | Level 7

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;

1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14

This might also provide some helpful information:

 

   http://robslink.com/SAS/book2/Chapter_07_Annotating_on_Maps.pdf

 

View solution in original post

7 REPLIES 7
GraphGuy
Meteorite | Level 14

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.

 

sophia_SAS
Obsidian | Level 7

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.

GraphGuy
Meteorite | Level 14

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).

 

sophia_SAS
Obsidian | Level 7

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

GraphGuy
Meteorite | Level 14

My best guess would be that the map and the annotated borders weren't projected exactly the same.

 

sophia_SAS
Obsidian | Level 7

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. 

GraphGuy
Meteorite | Level 14

This might also provide some helpful information:

 

   http://robslink.com/SAS/book2/Chapter_07_Annotating_on_Maps.pdf

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3093 views
  • 0 likes
  • 2 in conversation