Data visualization with SAS programming

PROC GMAP with census zipcode data. The border are crisscrossing across the entire map.

Reply
New Contributor
Posts: 2

PROC GMAP with census zipcode data. The border are crisscrossing across the entire map.

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;

New Contributor
Posts: 2

Re: PROC GMAP with census zipcode data. The border are crisscrossing across the entire map.

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

SAS Employee
Posts: 170

Re: PROC GMAP with census zipcode data. The border are crisscrossing across the entire map.

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

New Contributor
Posts: 2

Re: PROC GMAP with census zipcode data. The border are crisscrossing across the entire map.

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.

SAS Employee
Posts: 170

Re: PROC GMAP with census zipcode data. The border are crisscrossing across the entire map.

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.

Super User
Posts: 11,139

Re: PROC GMAP with census zipcode data. The border are crisscrossing across the entire map.

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

Contributor
Posts: 41

Re: PROC GMAP with census zipcode data. The border are crisscrossing across the entire map.

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.

SAS Employee
Posts: 170

Re: PROC GMAP with census zipcode data. The border are crisscrossing across the entire map.

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

Ask a Question
Discussion stats
  • 7 replies
  • 777 views
  • 0 likes
  • 5 in conversation