Data visualization with SAS programming

SAS CBSA Mapping

Accepted Solution Solved
Reply
Contributor
Posts: 20
Accepted Solution

SAS CBSA Mapping

[ Edited ]

I have uploaded a Zip code-CBSA crosswalk to SAS and merged it with the Sashelp.zipcode file in order to create a map of individual states at the CBSA level. To merge the two files I had to sort by zip code, and the problem is that the resulting map I created with the merged file (using proc gmap) is all scrambled inside. I know that SAS draws from point to point in the order of observations listed in the data/map files when it's mapping, but I don't know how to sort the dataset I have so that it draws CBSA boundaries nicely. I tried sorting by x and y coordinates individually, but that didn't help. Sorting by CBSA code also didn't help, as the numeric order of CBSA codes doesn't necessarily correspond to where they are geographically (and same goes for zip codes). I know it has to be based on pairs of x,y coordinates, but I don't know how to do this. Any suggestions/recommendations would be more than welcome. Thank you!!


Accepted Solutions
Solution
‎12-28-2015 11:26 AM
Grand Advisor
Posts: 16,265

Re: SAS CBSA Mapping

The zipcode file is centroids, and can't be used to draw state boundaries. You may need to import a SHP file from Census Bureau and use that create a map instead. Here's a quick reference on how to do that.

http://www.ats.ucla.edu/stat/sas/faq/gmap.htm

View solution in original post


All Replies
Grand Advisor
Posts: 16,265

Re: SAS CBSA Mapping

I'm not 100% following but could you add a row order variable to the dataset before the merge and then sort on it after?
Contributor
Posts: 20

Re: SAS CBSA Mapping

Thank you for your reply! That is a good idea and definitely makes sense. The only problem is that I'm not sure the SAShelp.Zipcode dataset comes in an order that makes sense for mapping to begin with. If you look at the Maps.State dataset, it's sorted by state, but within each state group, the x,y coordinates are sorted (by SAS, or whoever made the dataset) in a certain way that allows you to draw a map of the U.S. with nice statelines. The SAShelp.Zipcode comes sorted by zip code in ascending numeric order, which doesn't correspond to where they are on the map. I'm not even sure if it's possible to get an answer to this question on here, but I thought it couldn't hurt to ask. Thanks again for replying!

Solution
‎12-28-2015 11:26 AM
Grand Advisor
Posts: 16,265

Re: SAS CBSA Mapping

The zipcode file is centroids, and can't be used to draw state boundaries. You may need to import a SHP file from Census Bureau and use that create a map instead. Here's a quick reference on how to do that.

http://www.ats.ucla.edu/stat/sas/faq/gmap.htm
Contributor
Posts: 20

Re: SAS CBSA Mapping

Thanks a lot! I will give that a try.

SAS Employee
Posts: 170

Re: SAS CBSA Mapping

I think Reeza covered it all, but I can't get to that webpage.

I'm not sure why you want to mix ZIP Codes and CBSA's.

SASHELP.ZIPCODE is a point file and cannot be drawn as a map.  It can be used with Annotate.

The CBSA file is a boundary file and can be drawn as a map.  They should not be mixed.

There is a ZIP Code-like file from the Census called a ZCTA file.  And it is a boundary file.

 

Now, mixing these will not likely work.  CBSAs and ZIP Codes will cover the same area. 

 

Contributor
Posts: 20

Re: SAS CBSA Mapping

Thank you for your reply and explanation! I am relatively new to SAS and this is my first time ever trying to map with it, so I apologize if what I'm saying doesn't quite make sense. I didn't want to mix zip codes and CBSAs on a map, if that wasn't clear. I was having trouble finding a CBSA boundary file with x,y coordinates, so I was hoping to use the zip-CBSA crosswalk I had to link zip codes to CBSAs and then draw the map with the x,y coordinates that came with the zip code file. I understand now that the SASHELP.zipcode file isn't a boundary file, so that wouldn't work. Thanks again for your reply!

Contributor
Posts: 20

Re: SAS CBSA Mapping

As an update, I was able to get it to work by downloading a shp CBSA file from the Census Bureau website. As you suggested, no zip code file was necessary. Thanks to both of you for your help!

Post a Question
Discussion Stats
  • 7 replies
  • 536 views
  • 2 likes
  • 3 in conversation