BookmarkSubscribeRSS Feed
Ihsan-Mahdi
Quartz | Level 8

I created a map using this code:

data GCTest;
set XYZ.XXXX ;
ZIP=INPUT(IncidentZip, 8.);
Run;

data GCTest2;
set GCTest (rename=(Incident_Street_Address=Address
Incident_County_Name=County

Incident_City_Name=City));
State="WASHINGTON";

keep Address County ZIP City State;
Run;


proc geocode

method=street
data=GCTest2
LOOKUPSTREET=lookup.USM
OUT=GEOCODED
ATTRIBUTE_VAR=(countyfp Tract);
run;
quit;

%let name=mapping_6_tip;
filename odsout '.';
data geocoded; set geocoded (rename=(x=long y=lat state=statecode));
flag=1;
run;

data my_map; set mapsgfk.us_counties
(where=(statecode='WA') drop=resolution);
run;

data combined; set my_map geocoded (rename=( county=countyname countyfp=county));
run;
proc gproject data=combined out=combined latlong eastlong degrees;
id statecode county;
run;
data my_map geocoded; set combined;
if flag=1 then output geocoded;
else output my_map;
run;

data geocoded; set geocoded;
length function $8 color $8;
xsys='2'; ysys='2'; hsys='3'; when='a';
function='pie'; size=0.5; rotate=360;
style='psolid'; color='red'; output;
style='pempty'; color='cx4c2d00'; output;
run;


goptions device=png;
goptions border;

ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm"
(title="Mapping Tip #6 - Street-level Geocoding")
style=htmlblue;

goptions gunit=pct htitle=4 htext=4 ftitle="albany amt/bold" ftext="albany amt/bold";
goptions ctext=gray33;

pattern1 v=s c=cornsilk;

title1 ls=1.5 "XXXXXXXXX";
proc gmap data=my_map map=my_map anno=geocoded;
id state county;
choro segment / levels=1 nolegend
coutline=gray77
des='' name="&name";
run;

title h=20pt ' ';
footnote h=20pt ' ';

 

I would like to annotate the resulting map with county names. Is there a piece of code I could add to achieve that?

Thanks!

1 REPLY 1
ballardw
Super User

You add a Function to place the text into the annotate data set(s).

 

You may want to read the documentation associated with the %annomac macro. That macro defines a number of other macros that may using Annotate simpler, such as the %label macro that is intended to add what you want, placing text at a specified coordinate.