Data visualization with SAS programming

3-digit ZCTA data set

Reply
New Contributor
Posts: 2

3-digit ZCTA data set

Does anyone know of an existing (SAS or other) 3-digit zip code (zcta) data set? If not, what steps are needed to convert a 5-digit zip code data set to a 3-digit data set? (NOTE: I have the TigerLine 2013 US ZCTA510 data.) I believe it must be more than creating a new variable (3-digit zip code) from the existing 5-digit zip code.

Many thanks,

Gary

SAS Employee
Posts: 963

Re: 3-digit ZCTA data set

You would need to create the new 3-digit zip variable, and then use 'proc gremove' to remove all the internal boundaries within those 3-digit areas.

Here's the gremove doc:

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

New Contributor
Posts: 2

Re: 3-digit ZCTA data set

Thanks, Robert. Will the NODECYLE option in 'proc gremove' handle non-contiguous boundaries?

SAS Employee
Posts: 963

Re: 3-digit ZCTA data set

I would try it with no extra parameters/options first, and see how it looks. I think the way it handles non-contiguous areas is to give each one a different 'segment' number.

Occasional Contributor
Posts: 5

Re: 3-digit ZCTA data set

Hello, were you able to figure this out?  

Learner
Posts: 1

Re: 3-digit ZCTA data set

Gary, 

 

Were you able to convert the 5-digit zip to a 3-digit zip? If so, could you provide the SAS code to perform this conversion.  I am having trouble following the proc gremove steps provided. Thanks,

Tyler

SAS Employee
Posts: 963

Re: 3-digit ZCTA data set

Here's some code that imports a zcta boundary map, plots the zctas colored by zip3 ... and then gremoves the internal borders, and plots the zip3 polygons. This should be a good starting-point to get you going:

 

proc mapimport datafile="../democd17/zt37_d00.shp" out=zcta_map; 
 id zcta;  
run; 

proc gproject data=zcta_map (rename=(x=long y=lat)) out=zcta_map eastlong latlong degrees;
id zcta;
run;

data zcta_map; set zcta_map;
zip3=substr(zcta,1,3);
run;

proc gremove data=zcta_map out=zcta3_map;
by zip3;
id zcta;
run;

title ls=1.5 "NC Zip Code Map, Colored by zip3";
proc gmap data=zcta_map map=zcta_map all; 
id zcta; 
choro zip3 / coutline=gray cdefault=cxF5F5DC; 
run;

title ls=1.5 "NC Zip3 Map, Colored by zip3";
proc gmap data=zcta3_map map=zcta3_map all; 
id zip3; 
choro zip3 / coutline=gray cdefault=cxF5F5DC; 
run;

 

 

zip_3_boundaries.png

 

 

 

zip_3_boundaries1.png

 

 

Post a Question
Discussion Stats
  • 6 replies
  • 724 views
  • 0 likes
  • 4 in conversation