Hello everyone again. Hopefully this will be my last post on this subject. My map looks fairly good thanks to the help of all of you out there. I just have one problem and i can't seem to figure it out. It's the labels for the Ottawa (123) & Erie (43). See how messed they are. I tried playing with the postion code and it managed to the county & number close to each other. I someone can help me figure out those 2 counties. I tried if then statements but i proc gproject data=maps.counties out=ohio;
/* State FIPS for Ohio */
where state=39;
id state county;
run;
quit;
proc sort data=mapsgfk.us_counties out=centroids;
by state county segment;
run;
data centroids_temp;
retain yi yj xi xj a cx cy x0 y0 0;
set centroids(keep=state county segment lat long rename=(lat=yj long=xj));
by state county segment;
if(first.segment) then do;
cx = 0;
cy = 0;
a = 0;
x0 = xj;
y0 = yj;
end;
else if(not first.segment) then do;
ta = (xi*yj - xj*yi);
cx + ((xi+xj)*ta);
cy + ((yi+yj)*ta);
a + ta;
end;
if(last.segment) then do;
ta = (xj*y0 - x0*yj);
cx + ((xj+x0)*ta);
cy + ((yj+y0)*ta);
a = ta + a * 0.5;
cx = cx / (6*a);
cy = cy / (6*a);
output;
end;
xi = xj;
yi = yj;
run;
proc sql;
create table centroid_weight as
select
state, county, sum(a) as sum
from centroids_temp
group by state, county;
quit;
proc sql;
create table centroids as
select a.state, a.county,
sum(cx*(a / sum)) as lat,
sum(cy*(a / sum)) as long
from centroids_temp a
inner join centroid_weight b
on (a.state = b.state and a.county = b.county)
group by a.state, a.county;
quit;
proc sql;
drop table centroids_temp;
drop table centroid_weight;
quit;
PROC SQL;
CREATE TABLE WORK.FILTER_FOR_CENTROIDS AS
SELECT t1.STATE,
t1.COUNTY,
t1.lat,
t1.long
FROM WORK.CENTROIDS t1
WHERE t1.STATE = 39;
QUIT;
proc format library=work;
value ohiohos_
1 = '1'
2 = '2'
3 - 5 = '3 - 5'
6 - 7 = '6 - 7'
7 - 21 = '7 or more'
;
run;
data work.numofhos0;
input county ohiohos @@;
HospText = put(ohiohos,ohiohos_.);
datalines;
001 1 003 5 005 1 007 3
009 2 011 1 013 3 015 0
017 5 019 0 021 1 023 3
025 1 027 1 029 2 031 1
033 2 035 21 037 1 039 3
041 1 043 1 045 2 047 1
049 17 051 1 053 1 055 2
057 2 059 2 061 16 063 2
065 1 067 1 069 1 071 2
073 1 075 1 077 2 079 1
081 3 083 1 085 2 087 1
089 1 091 1 093 5 095 13
097 1 099 7 101 1 103 2
105 0 107 1 109 1 111 0
113 12 115 0 117 1 119 2
121 0 123 1 125 1 127 0
129 1 131 1 133 1 135 0
137 0 139 3 141 1 143 3
145 2 147 1 149 1 151 6
153 12 155 4 157 3 159 1
161 2 163 0 165 1 167 2
169 2 171 2 173 1 175 1
;
run;
proc sql;
create table work.ohnames as
select distinct county, countynm label='County Name'
from sashelp.zipcode
where state=39;
quit;
%annomac;
%maplabel(work.ohio,work.ohnames,work.nameanno,countynm, county,font='Albany AMT/''boldt',
color=black,size=1.7);
%maplabel(work.ohio,work.numofhos0,work.Hospanno,ohiohos, county,font='Albany AMT/''boldt',
color=black,size=1.8);
data work.combinedanno;
set
WORK.CENTROIDS
work.nameanno (in=Name)
WORK.CENTROIDS
work.Hospanno (in=Hosp);
if Name then position = '2.1';
Else if Hosp then position = '5';
/* this is where you could put if statements to adjust
the x and or y coordinates to display name or value
*/
;
run;
title1 "Map of Ohio Hospitals By County";
/* Generate a county map of Ohio with county labels */
pattern1 v=s color=azure;
pattern2 v=s c=grayda;
pattern3 v=s color=biy;
pattern4 v=s color=bisque;
pattern5 v=s c=bibg;
pattern6 v=s color=cyan;
proc gmap data=work.numofhos0 map=work.ohio;
id county;
choro ohiohos / anno=work.combinedanno
discrete
coutline=black
;
format ohiohos ohiohos_.;
label ohiohos= "Number of Hospitals";
run;
quit; title;
guess i can;t figure out which variable i need to alter. Thanks again everyone, take care
... View more