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

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!!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
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

7 REPLIES 7
Reeza
Super User
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?
osi814
Obsidian | Level 7

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!

Reeza
Super User
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
osi814
Obsidian | Level 7

Thanks a lot! I will give that a try.

Darrell_sas
SAS Employee

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. 

 

osi814
Obsidian | Level 7

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!

osi814
Obsidian | Level 7

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!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 2517 views
  • 2 likes
  • 3 in conversation