I feel like I will not be ablt to ask questions fast enough. I work for the department of public health and am using the data we have to plot disease incidence within our 6 county district down to the address. So far i have successfully geocoded my data and that is about it.
Currently I need to figure out how to:
The department of public health divides their districts into unique groups so no real shapfile exists for my district. If I use a shapefile that spans the entire state is there a way to focus in on just the 6 county area that the data will be confied to? If I can not effectively zoom in on our area of intrest, is there a way to merge shapefiles from different counties to effectively create the shapefile I need?
I am very unclear on what an annotated data set is at the moment. I beleive that it essentially is a set of instructions for SAS on how to display the geocodded data onto the map but I am not sure where exactly to start.
I was told that there are three components, the map dataset, annotated dataset and the response dataset. I believe that the line betweeen the reponse and annotated are starting to blur together for me and I need the diffrerences.
I am a visual learner. There are no videos on youtube or on the SAS website which i can see someone created and run code from start to finish in geocoding. Talking on the phone to SAS techical support helps but only goes so far. Below is the example code that I received from a tech this afternoon but I have been unable to get them back on the phone to help walk me through.
If there is anyone who would be able to walk me through the process, step-by-step of importing a map from shapefiles, writing annotated dataset code and then running it to get an point graph, I would be forever greatful. Please feel free to edit and add to the sample code I have below.
/* use the address of some of the Visitor Centers in Georgia */ data address; input address $18. @20 city $10. state $ zip; datalines; 1751 Williams Road Columbus GA 31904 2424 Haddock Road Kingsland GA 31548 938 County Road 84 Lavonia GA 30553 1763 U.S. Hwy. 280 Plains GA 31780 ; run; /* Assuming the lookup data has been imported and stored in a library named LOOKUP */ proc geocode data=address out=geocoded method=street lookupstreet=lookup.usm attributevar=(tract); run; data annotate; set geocoded(keep=x y address city state zip rename=(state=stname));; retain xsys ysys '2' when 'a' function 'label'; length color $8; /* create a STATE variable that contains the FIPS codes to match the map data */ state=stfips(stname); /* convert X and Y in the geocode data set to radians to match the map */ x=atan(1)/45 * x ; y=atan(1)/45 * y; /* adjust the hemisphere for the longitude to match the map data set */ x=-x; style='special'; text='J'; position='5'; size=2; /* change the color of the dot based on some value */ select; when (city='Columbus') color='red'; when (city='Kingsland') color='blue'; when (city='Lavonia') color='lib'; when (city='Plains') color='orange'; otherwise color='black'; end; run; /* combine annotate data set with unprojected map data */ data all; set maps.county(where=(state=13)) annotate; run; /* project the data */ proc gproject data=all out=allp dupok; id state county; run; /* separate the annotate and map data sets */ data map anno; set allp; if when='a' then output anno; else output map; run; /* set the map patterns to be empty */ pattern1 v=me c=black r=99; proc gmap data=map map=map; id state county; choro county / anno=anno nolegend; run; quit;
If your map data set (after importing) has a variable to indicate county you should be able to make your regional map with something like:
Data myregionmap; set statemap; where countyvariable in (county1, county2, county3, county4...); run;
where county1 would either be the numeric value (county code perhaps if numeric) or the text value "name of county" or "text code".
An annotate data set is a set of coordinates and instructions to place text, symbols or draw lines or polygons. To use with a map data set then the x and y coordinates have to match those used in the map data set. Annotate sets are completely optional though when placing things like a city or county name symbol then that's the way to go.
A response data set has more to do with map regions when using Proc GMAP. The ID variable indicates the identifier for the region and your response set has the ID and response value to display (or possibly allow the procedure to sum, count or average). Point data, such as city/clinic/service point would be in an annotate set.
Please note that there a bunch of macros to help work with annotate data sets. %annomac should be included if you have SAS/Graph to use Proc Gmap.
One resource you want to know is http://robslink.com/SAS/ This website has a large number of different maps, some from the SAS examples others using other data sources and show complete code. You can browse through many pages of image thumbnails to find something like what you may want and find code and data in links.
I would suggest using this as your starting point ...
input address $18. @20 city $10. state $ zip;
1751 Williams Road Columbus GA 31904
2424 Haddock Road Kingsland GA 31548
938 County Road 84 Lavonia GA 30553
1763 U.S. Hwy. 280 Plains GA 31780
libname lookup '\\spldell5-new\GEOCODE lookup data\2015 US streets (9.4)\';
proc geocode data=my_data out=my_data (rename=(x=long y=lat))
data my_map; set mapsgfk.us_counties (where=(statecode='GA'));
proc gproject data=my_map out=my_map latlong eastlong degrees dupok
proc gproject data=my_data out=my_data latlong eastlong degrees dupok
data my_anno; set my_data;
length function $8 color $12;
xsys='2'; ysys='2'; hsys='3'; when='a';
function='pie'; size=1.0; rotate=360;
if (city='Columbus') then color='red';
else if (city='Kingsland') then color='blue';
else if (city='Lavonia') then color='lib';
else if (city='Plains') then color='orange';
style='empty'; color='gray77'; output;
pattern1 v=s c=white;
title1 ls=1.5 "Lat/Long Markers on Map";
proc gmap data=my_map map=my_map all anno=my_anno;
choro segment / levels=1 nolegend coutline=grayaa;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.