BookmarkSubscribeRSS Feed
rcleven2
Obsidian | Level 7

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:

Proc ImportMap

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?

 

Annotated dataset

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.

 

Response

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;
 

 

 

 

2 REPLIES 2
ballardw
Super User

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.

GraphGuy
Meteorite | Level 14

I would suggest using this as your starting point ...

 

 

data my_data;
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;

 

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))
method=street lookupstreet=lookup.usm;
run;


data my_map; set mapsgfk.us_counties (where=(statecode='GA'));
run;

 

proc gproject data=my_map out=my_map latlong eastlong degrees dupok
parmout=work.projparm;
id id;
run;

 

proc gproject data=my_data out=my_data latlong eastlong degrees dupok
parmin=work.projparm parmentry=my_map;
id;
run;

 

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';
else color='black';
style='solid'; output;
style='empty'; color='gray77'; output;
run;

 

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;
id id;
choro segment / levels=1 nolegend coutline=grayaa;
run;

 

health.png

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 2 replies
  • 1029 views
  • 0 likes
  • 3 in conversation