Data visualization with SAS programming

CBSA and State boundaries gmap

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 104
Accepted Solution

CBSA and State boundaries gmap

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;


Accepted Solutions
Solution
‎12-02-2015 02:09 PM
SAS Employee
Posts: 980

Re: CBSA and State boundaries gmap

This might also provide some helpful information:

 

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

 

View solution in original post


All Replies
SAS Employee
Posts: 980

Re: CBSA and State boundaries gmap

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.

 

Frequent Contributor
Posts: 104

Re: CBSA and State boundaries gmap

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.

SAS Employee
Posts: 980

Re: CBSA and State boundaries gmap

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

 

Frequent Contributor
Posts: 104

Re: CBSA and State boundaries gmap

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

SAS Employee
Posts: 980

Re: CBSA and State boundaries gmap

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

 

Frequent Contributor
Posts: 104

Re: CBSA and State boundaries gmap

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. 

Solution
‎12-02-2015 02:09 PM
SAS Employee
Posts: 980

Re: CBSA and State boundaries gmap

This might also provide some helpful information:

 

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

 

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 844 views
  • 0 likes
  • 2 in conversation