data Active_patients (rename=(cw_state=state death=dateofdeath close=dateclosed zipc=zip ));
length first $40;
length last $40;
length cw_state $2;
drop first_name state dateofdeath date_death dateclosed date_clos zip 'HIV Date'n 'Enrl Date'n;
retain urn last first middle;
set hivcc."Grey's Active Patients List$"n;
last=propcase(scan(name,1," ,-"));
first_name=propcase(scan(name,-1,","));
first=propcase(scan(first_name,1," "));
middle=propcase(scan(first_name,2," "));
hivdate=input('HIV Date'n,mmddyy10.);
enrldate=input('Enrl Date'n,mmddyy10.);
date_death=scan(dateofdeath,1," ");
death=input(date_death,mmddyy10.);
date_clos=scan(dateclosed,1," ");
close=input(date_clos,mmddyy10.);
format close death hivdate enrldate mmddyy10.;
zipc=input(zip,5.);
if state = "Georgia" then cw_state = "GA";
else if state = "Tennessee" then cw_state = "TN";
else if state = "Florida" then cw_state = "GA";
if county = " " then county = "Whitfield";
if county = "De Kalb" then county="DeKalb";
run;
proc sort data=work.active_patients;
by urn;
run;
proc sort data=newadd.'''Print 1 - Data Set WORK#BAD_$'''n out=new_add;
by urn;
run;
proc sort data=newadd2.'''Print 1 - Data Set WORK#BAD_$'''n out=new_add2;
by urn;
run;
data updated_addresses(rename=(state=statecode county=county_name));
merge work.active_patients work.new_add work.new_add2;
by urn;
run;
proc sort data=updated_addresses nodupkey;
by urn;
run;
proc sort data=updated_addresses;
by statecode county_name;
run;
proc sort data=mapsgfk.us_counties_attr out=county_fips(rename=(idname=county_name)) ;
by statecode idname;
where state=13;
run;
data new_list (rename=(statecode=state state=state_fips));
length patient_type $1;
length point $1;
length county_name $55;
merge work.updated_addresses(in=a) work.county_fips(keep=county county_name state statecode in=b);
by statecode county_name;
if b and not a then delete;
if state ne 13 then delete;
if year(hivdate)=2017 then do;
patient_type="1";
point='L';
end;
else if year(hivdate)<=2016 and year(enrldate)=2017 then do;
patient_type="2";
point='M';
end;
else if year(hivdate)<=2016 and year(enrldate)<=2016 then do;
patient_type="3";
point='J';
end;
run;
/*****************************************************************************************************/
/* NOTE!!!! Instert Data provided here into the data= portion of Proc Geocode */
proc geocode data=work.new_list lookupstreet=maps.usm out=geocoded method=street ;
run;
options mprint;
%helpano(all)
%annomac()
data annotate_dots(keep=x y state_fips county _status_ name when text color style size xsys ysys hsys rename=(state_fips=state));
%dclanno
length text $60;
length state_fips 5;
set geocoded(rename=(m_state=stname) drop=state);
where _status_="Found";
/* LABEL(x1, y1, text, color, ang, rot, ht, font, pos)*/
%system(2,2,1);
when='a';
if patient_type="1" then color='crimson';
else if patient_type="2" then color='gold';
else if patient_type="3" then color='lip';
%label(x,y,point,*,0,0,4,'Special',5);
if color='crimson' then size=5;
output;
run;
proc sort data=annotate_dots;
by descending color;
run;
data gacounties(rename=(long=x lat=y));
set mapsgfk.us_counties(drop=x y where=(state=13));
run;
/* Combine datasets */
data all;
set gacounties annotate_dots;
run;
/* project the data */
proc gproject data=all out=allp dupok degree eastlong;
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;
/* Subset dataset to be graphed */
data district_anno;
set anno;
if county = 115 then delete;
if county in(57 111 123 213 227 313) then output;
else if county not in(57 111 123 213 227 313) and color='crimson' then output;
run;
data districtmap;
set map;
where county in(57 111 123 213 227 313);
run;
data anno_legend;
%dclanno
length text $50;
%system(3,3,1);
%label(3,15,'L',crimson,0,0,6,'Special',5);
%label(5,15,'New Positive',black,0,0,4,'Thorndale AMT',6);
%label(3,10,'M',gold,0,0,6,'Special',5);
%label(5,10,'New to TLBC',black,0,0,4,'Thorndale AMT',6);
%label(3,5,'J',lip,0,0,6,'Special',5);
%label(5,5,'Previously Entered into Care',black,0,0,4,'Thorndale AMT',6);
output;
run;
goptions reset=all device=png;
ods html path="c:\users\rgclevenger\desktop\Maps" (url=none) file="hiv_map.html" ;
proc gmap data=districtmap map=districtmap all anno=anno ;
id state county;
choro state / nolegend;
pattern1 v=s c=cornflowerblue;
run;
proc gmap data=districtmap map=districtmap all anno=district_anno ;
id state county;
choro state / nolegend anno=anno_legend;
pattern1 v=s c=lig;
run;
ods html close;
ods listing; Using Proc Gmap I have geocoded and projected my maps and annotations correctly. Now all that I am trying to do to finalize this project is get the names of the individual plotted points to show up when I hover over them with my mouse. I have supplied my entire code and a sample set of data that anyone can use. Help me Obi-Wan, you are my only hope. BONUS POINTS if anyone can tell me why I keep getting this warning message and how to fix it. My OCD can't stand seeing Warning messages. ----WARNING: Some observations were discarded when charting STATE. Only first matching observation was used. Use STATISTIC= option for summary statistics.
... View more