09-15-2017 01:08 PM
I'm creating geomaps in 7.4 VA. I’ve got SCFs I’d like to use and it only takes 5 digit zips. I’ve tried adding zeros to the end but that really didn’t work. They all showed up in Washington DC. Do you have any suggestions?
09-17-2017 05:54 PM
I'm not too familiar with SCF's but I doubt that just by adding zeros to the end would make it a valid post code? Also, given details on https://en.wikipedia.org/wiki/Sectional_center_facility some SCF's are served by other state facilities - so just referencing the underlying postcode may give false information.
One way to get this solved would be to download a reference data set such as http://faculty.baruch.cuny.edu/geoportal/data/esri/usa/census/zip3.zip (there may be others if you google) which contains the polygonal areas of SCF's. Either follow the VA admin guide to import these custom polygons into VA or just use the data to extract the coordinates for each SCF. This way you can merge the coordinates back to your source data and create a custom geographical item instead. Something like this I guess:
proc mapimport datafile="C:\temp\zip3.shp" out=data.zip3; id ZIP3; run; proc sql; create table work.scf_coordiantes as select distinct zip3, avg(x) as longitude, avg(y) as latitude from data.zip3 group by zip3; quit;run;
Hope this helps!
09-19-2017 02:01 AM
I saw your post about SCFs and yesterday @Rick_SAS wrote about SCFs in a zip code blog post he wrote. Thought I'd share it in the thread as he has code on how to create the SCFs.
09-19-2017 09:24 AM
Thanks everyone. You all have inspired me to the following solution.
An SCF is the first 3 digits of a zip code. I needed to get a Latitude/Longitude for an SCF. So I took the first and last coordinates of each zipcode in an SCF, divided by 2 and "close enough for my needs" got the geographical center for an SCF and it's associated Lat/Long. These coordinates are used in SAS VA to create a bubble map of the US.
data scf_zip; set sashelp.zipcode(where=(StateCode
NOT IN ("PR", "FM", "GU", "MH", "MP", "PW", "VI")
AND ZIP_Class = " "));
scf = substr(put(zip,z5.),1,3);
keep scf zip x y;
proc sort data=scf_zip; by scf;
data scf(rename=(newx=x newy=y)); set scf_zip;
retain x1 y1 0;
if first.scf then do;
x1 = x;
y1 = y;
if last.scf then do;
x2 = x;
y2 = y;
if last.scf then do;
newx = sum(x1,x2)/2;
newy = sum(y1,y2)/2;
keep scf newx newy;
09-19-2017 05:15 PM
Nice! Glad you got this sorted!!
I also got inspired and couldn't resist trying out the SCF paths @Rick_SAS wrote about in the blog shared by @MichelleHomes using SAS Visual Analytics 8.x. After running the code shared in the blog - I submitted the following to create the final network data set for VA:
proc sql; create table geo.scf_paths as select scf,xx as longitude, yy as latitude, count(zip) as zipcount, statecode,path from work.state group by scf; quit;run; data geo.scf_paths; set geo.scf_paths(where=(path ne .)) end=last; length scf_source $5 longitude_source 8. latitude_source 8.; length scf_target $5 longitude_target 8. latitude_target 8.; by scf; if first.SCF and _n_ gt 1 then do; scf_target = scf; longitude_target = longitude; latitude_target = latitude; output; end; scf_source = scf; longitude_source = longitude; latitude_source = latitude; if last then do; scf_target = ""; longitude_target = .; latitude_target = .; output; end; retain scf_source longitude_source latitude_source; drop scf longitude latitude; run;
In VA 8.x it renders like this:
I guess once we know the coordinates for SCF's we have a few more options for interesting visualizations!
09-20-2017 10:01 AM
09-20-2017 05:06 PM
I guess if you want to properly determine the SCF's location you probably need to get the boundary data set as per link in my first reply and determine the centroid for each polygon. After all - a SCF is an area not a location. There are various ways to do this including the official SAS/GRAPH %CENTROID macro, one @SanjayM wrote or via SAS/IML as outlined in another post from Rick.
Since VA 7.4 and upcoming VA 8.2 support custom polygons - the best solution may however to import the boundary data set and render a regional map