BookmarkSubscribeRSS Feed
fengyuwuzu
Pyrite | Level 9

my data has zip code column, and we want to see which area of the state has more of the IDs.

One way is to color the zip code on the state map, with color related by zip code frequency

 

Is there a way to do this in SAS with gmap? Does any one know such an example?

 

thanks

7 REPLIES 7
ballardw
Super User

First question: Do you have a MAP dataset with Zipcode boundaries? Or are you going to use a center of mass for each Zipcode?

Note: on many STATE level maps Zip code areas can be so small not to be visible, especially if any of the Zip codes you use are of the single building (company) variety.

 

Do you want to show specific levels of counts such as 1 to 10, 11 to 50, 51 to 100 Ids with each Group having an separate color or a gradient based on count?

 

Also consider using cirles where the radius indicates number if you have lots of Zip codes close together.

fengyuwuzu
Pyrite | Level 9
You are right. Zip code area may be too small. We are thinking group then into 8 regions.

gradient color map may be better; but if it is too hard, color at different levels is also ok.

I tried to download the ZCTA files with the links in this post: https://communities.sas.com/t5/SAS-GRAPH-and-ODS-Graphics/One-County-with-Zips-Map/td-p/77822 but the inks did not work.
ballardw
Super User

Depending on the state the ZCTA has lots of holes in it and may not look very good. You may consider county as the SASHELP.ZIPCODE would help match the zip to counties for counting and then use one of the SAS supplied county map data sets.

fengyuwuzu
Pyrite | Level 9

Thank you, Ballardw.
I know zipname can return state name, zipcity can return city, is there a zip function can return counties?

ballardw
Super User

Use a Proc SQL join.Note that the Zip code dataset also has latitude and longitude for approximate center if that might be helpful.

 

(pseudo code as I am away from my SAS install)

proc sql;
   create table MyStateZips as
   select distinct zip, county
   from sashelp.zipcodes
where statecode = 'XX'; quit;

to get zipcodes for a single state of interest.

Then to look up the county name something like

Proc sql;
   create MyMergeData as
   select have.*, MyStateZips.county
   from have left join MyStateZips on
      have.zip = MyStateZips.zip;
quit;
   

If you are working in multiple states then you would have to add the state values to the select in the first bit and add to the join in the second.

 

 

I actually pulled a unique list of Zip code/county name values for my state of interest and built a number of formats and informats to do the common transformations as I have the opportunity to do something with Zip codes moderately often. I also made sure my county map dataset had numeric and text values for such things as the Fips code, county sequence number as well as county name so that I could often go to mapping with most likely types of county identifiers.

Rick_SAS
SAS Super FREQ

A slightly different approach: Many statisticians who are interested in spatial data analysis use metropolitan statistical areas (MSAs) instead of zip codes.  MSAs are used by the US census bureau.

fengyuwuzu
Pyrite | Level 9

I realized drawing a map and color the zipcode or region on the map takes a lot of work.

so maybe I do not need such a fancy map but just some charts.

 

Thanks a lot for all replies.

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
  • 1705 views
  • 0 likes
  • 3 in conversation