Hello All,
I am attempting to create a map of the State of Ohio and the number of hospitals in each county. I would like to create a map that allows you to hover over the county and see the name of county and the number of hospitals. I attempted to follow the code in example 11 the 251- 29 paper, but I'm missing a step somewhere. At some point in time, I will need to add the actual names of the hospitals in the pop up, but for now, if I could get the name of the county & the number of hospitals to work, I may be able to figure out how to add the names. Any advice would be greatly appreciated. thanks in advance.
001 | Adams County | 2 |
003 | Allen County | 5 |
005 | Ashland County | 1 |
007 | Ashtabula County | 4 |
009 | Athens County | 2 |
011 | Auglaize County | 1 |
013 | Belmont County | 3 |
015 | Brown County | 1 |
017 | Butler County | 5 |
019 | Carroll County | 0 |
021 | Champaign County | 1 |
023 | Clark County | 3 |
025 | Clermont County | 1 |
027 | Clinton County | 1 |
029 | Columbiana County | 2 |
031 | Coshocton County | 1 |
033 | Crawford County | 2 |
035 | Cuyahoga County | 23 |
037 | Darke County | 1 |
039 | Defiance County | 3 |
041 | Delaware County | 2 |
043 | Erie County | 1 |
045 | Fairfield County | 2 |
047 | Fayette County | 2 |
049 | Franklin County | 21 |
051 | Fulton County | 1 |
053 | Gallia County | 1 |
055 | Geauga County | 1 |
057 | Greene County | 2 |
059 | Guernsey County | 2 |
061 | Hamilton County | 18 |
063 | Hancock County | 2 |
065 | Hardin County | 1 |
067 | Harrison County | 1 |
069 | Henry County | 1 |
071 | Highland County | 2 |
073 | Hocking County | 1 |
075 | Holmes County | 1 |
077 | Huron County | 2 |
079 | Jackson County | 1 |
081 | Jefferson County | 2 |
083 | Knox County | 1 |
085 | Lake County | 2 |
087 | Lawrence County | 1 |
089 | Licking County | 1 |
091 | Logan County | 1 |
093 | Lorain County | 8 |
095 | Lucas County | 16 |
097 | Madison County | 1 |
099 | Mahoning County | 6 |
101 | Marion County | 1 |
103 | Medina County | 2 |
105 | Meigs County | 0 |
107 | Mercer County | 1 |
109 | Miami County | 2 |
111 | Monroe County | 0 |
113 | Montgomery County | 11 |
115 | Morgan County | 0 |
117 | Morrow County | 1 |
119 | Muskingum County | 2 |
121 | Noble County | 0 |
123 | Ottawa County | 1 |
125 | Paulding County | 1 |
127 | Perry County | 0 |
129 | Pickaway County | 2 |
131 | Pike County | 1 |
133 | Portage County | 1 |
135 | Preble County | 0 |
137 | Putnam County | 0 |
139 | Richland County | 3 |
141 | Ross County | 1 |
143 | Sandusky County | 2 |
145 | Scioto County | 2 |
147 | Seneca County | 2 |
149 | Shelby County | 1 |
151 | Stark County | 6 |
153 | Summit County | 11 |
155 | Trumbull County | 5 |
157 | Tuscarawas County | 2 |
159 | Union County | 1 |
161 | Van Wert County | 2 |
163 | Vinton County | 0 |
165 | Warren County | 2 |
167 | Washington County | 2 |
169 | Wayne County | 2 |
171 | Williams County | 2 |
173 | Wood County | 1 |
175 | Wyandot County | 1 |
Hey @10134458! Here's how you can do it:
You can get the mapsgfk county IDs by merging your county data with it using DATA Step merge or SQL join, but in this case I'll choose to use a hash lookup.
At the bottom of this post is your data in CSV format.
data hospital_count2;
length id $10.;
set hospital_count;
/* Create a lookup table for the mapsgfk County ID for Ohio counties */
if(_N_ = 1) then do;
dcl hash lookup(dataset: "mapsgfk.us_counties_attr(where=(statecode='OH'))");
lookup.defineKey('county');
lookup.defineData('id');
lookup.defineDone();
end;
/* Get the mapsgfk county ID based on the state's county ID */
rc = lookup.Find();
/* Create a hover-over of info with a line break, '0D'x */
hover_over=cat('title="County: ', strip(county_name), '0D'x, 'Count: ', count, '"');
drop rc;
run;
proc gmap data = hospital_count2
map = mapsgfk.us_counties;
id id;
choro count / html=hover_over;
run;
Data:
county,county_name,Count
1,Adams,2
3,Allen,5
5,Ashland,1
7,Ashtabula,4
9,Athens,2
11,Auglaize,1
13,Belmont,3
15,Brown,1
17,Butler,5
19,Carroll,0
21,Champaign,1
23,Clark,3
25,Clermont,1
27,Clinton,1
29,Columbiana,2
31,Coshocton,1
33,Crawford,2
35,Cuyahoga,23
37,Darke,1
39,Defiance,3
41,Delaware,2
43,Erie,1
45,Fairfield,2
47,Fayette,2
49,Franklin,21
51,Fulton,1
53,Gallia,1
55,Geauga,1
57,Greene,2
59,Guernsey,2
61,Hamilton,18
63,Hancock,2
65,Hardin,1
67,Harrison,1
69,Henry,1
71,Highland,2
73,Hocking,1
75,Holmes,1
77,Huron,2
79,Jackson,1
81,Jefferson,2
83,Knox,1
85,Lake,2
87,Lawrence,1
89,Licking,1
91,Logan,1
93,Lorain,8
95,Lucas,16
97,Madison,1
99,Mahoning,6
101,Marion,1
103,Medina,2
105,Meigs,0
107,Mercer,1
109,Miami,2
111,Monroe,0
113,Montgomery,11
115,Morgan,0
117,Morrow,1
119,Muskingum,2
121,Noble,0
123,Ottawa,1
125,Paulding,1
127,Perry,0
129,Pickaway,2
131,Pike,1
133,Portage,1
135,Preble,0
137,Putnam,0
139,Richland,3
141,Ross,1
143,Sandusky,2
145,Scioto,2
147,Seneca,2
149,Shelby,1
151,Stark,6
153,Summit,11
155,Trumbull,5
157,Tuscarawas,2
159,Union,1
161,Van Wert,2
163,Vinton,0
165,Warren,2
167,Washington,2
169,Wayne,2
171,Williams,2
173,Wood,1
175,Wyandot,1
So cool!
I truly want to thank @Stu_SAS so much for replying. I have managed to add the hospital count with a variable named count. I will hopefully be able to figure out the rest of your post. Thank you so much for responding.
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.
Ready to level-up your skills? Choose your own adventure.