BookmarkSubscribeRSS Feed
Harvey_D
Calcite | Level 5

Hello,

I downloaded census data files with zip code coordinates. the files are tl_2013_us_zcta510.dbf, tl_2013_us_zcta510.shx, and tl_2013_us_zcta510.shp from the census data site. the census site location is http://www.census.gov/cgi-bin/geo/shapefiles2013/layers.cgi

I am trying to create a gmap by zip code. I can do it just fine by county and state, but not by city or zip code. When I try and do it by zip code using the census data the black border lines are filling in much of the map making it useless. What gives? Below are the basics of my process, I tried attaching a screenshot of the map but the forum won't let me.

Thanks, I appreciate all help and comments.

/* importing the census data for zip code coordinates*/

proc mapimport datafile="/folder/proj/&dir/&user/Notes/&prj/Data/tl_2013_us_zcta510.shp"

              out=zipdata;

run;

/*importing a file containing a list of all florida zip codes */

      Data FL_Zips;

  infile "/folder/proj/&dir/&user/Notes/&prj/Data/FL_Zips.csv"

          dlm=',' dsd firstobs=3;

      input    Zipcode  :  $5.;

    format zipcode $5.    ;

    run;

/* filter so the map data set only contains florida zips */

proc sql; create table zipdata2 as

select distinct t1.ZCTA5CE10 as Census_Zip,

                    t1.X,

                    t1.Y

from zipdata t1 left join FL_Zips t2 on (t1.ZCTA5CE10=t2.Zipcode)

where t2.zipcode is not missing

order by Census_Zip;quit;

/* attempting to create the map that outlines the zip codes in Florida. This creates a map where the border of Florida is accurate, but the interior of the map is mostly the black border  filling in all over the place */

proc gmap=zipdata2 map=zipdata2;

census_zip;

choro census_zip;

run;

quit;

7 REPLIES 7
kmp26
Calcite | Level 5

Hi, I am facing the same problem too. wondering if you found any solution to fix this.  Trying to gmap by zipcode and all I see is the borders criss-crossing and black lines all over the map. Please let me know if you found any solution to this. I was trying to map some zipcodes of locations on a  county map.  Thanks

Darrell_sas
SAS Employee

The Census data is not sorted by the ZCTA variable (zip code).  You must use the ID statement with the ZCTA data set on Proc MAPIMPORT.

proc mapimport datafile="/folder/proj/&dir/&user/Notes/&prj/Data/tl_2013_us_zcta510.shp"

              out=zipdata;

        id zcta5ce10;   

run;

SAS/GRAPH(R) 9.4: Reference, Third Edition

kmp26
Calcite | Level 5

Thank you so much Darrell. Id statement did fix the problem. One more question though, I actually have street addresses to map, I work on SAS enterprise guide and do not have access to sas/gis tool. Is there any other way to geocode the exact street addresses without the sas/gis tool? I am new to this, and just learning about gmap and geocoding. Thanks a lot for your Tips and tricks papers.

Darrell_sas
SAS Employee

Yes.  In SAS/Graph, there is Proc GEOCODE.  It will geocode street addresses.  Plus geocode a lot of other ways.

Look at our paper: http://support.sas.com/rnd/papers/#2013 PROC GEOCODE: Finding Locations Outside the U.S. 

There is a paper and examples.

You might look through the other papers in http://support.sas.com/rnd/papers.  There are a number of Mapping papers in there that might be useful.  Most have zipfiles with examples which can be useful.

ballardw
Super User

Note also that not geographic areas are assigned a ZIP code in that data.

FrankPoppe
Quartz | Level 8

When selecting the Florida zip-codes you order by Census_zip.

This may disrupt the order of the individual X-Y-observations within each value for Census_zip, which would lead to criss-crossing lines.

I am not sure that is the case here, but it is safer to add a sequence-value to the observations first (in a data step: seqNum=_N_); and use that to order by as well.

Darrell_sas
SAS Employee

To Harvey_D, you can sort by just Florida by looking at the ZCTA code rather than having a list of "ZIP Codes".  Florida is 32xxx to 34xxxx.  So you can sort your ZIPDATA data set by looking at the first two characters of the ZCTA.  ZCTA codes are not exactly ZIP Codes.

List of ZIP code prefixes - Wikipedia, the free encyclopedia

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
  • 1971 views
  • 0 likes
  • 5 in conversation