BookmarkSubscribeRSS Feed
10134458
Calcite | Level 5

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. 

 

001Adams County2
003Allen County5
005Ashland County1
007Ashtabula County4
009Athens County2
011Auglaize County1
013Belmont County3
015Brown County1
017Butler County5
019Carroll County0
021Champaign County1
023Clark County3
025Clermont County1
027Clinton County1
029Columbiana County2
031Coshocton County1
033Crawford County2
035Cuyahoga County23
037Darke County1
039Defiance County3
041Delaware County2
043Erie County1
045Fairfield County2
047Fayette County2
049Franklin County21
051Fulton County1
053Gallia County1
055Geauga County1
057Greene County2
059Guernsey County2
061Hamilton County18
063Hancock County2
065Hardin County1
067Harrison County1
069Henry County1
071Highland County2
073Hocking County1
075Holmes County1
077Huron County2
079Jackson County1
081Jefferson County2
083Knox County1
085Lake County2
087Lawrence County1
089Licking County1
091Logan County1
093Lorain County8
095Lucas County16
097Madison County1
099Mahoning County6
101Marion County1
103Medina County2
105Meigs County0
107Mercer County1
109Miami County2
111Monroe County0
113Montgomery County11
115Morgan County0
117Morrow County1
119Muskingum County2
121Noble County0
123Ottawa County1
125Paulding County1
127Perry County0
129Pickaway County2
131Pike County1
133Portage County1
135Preble County0
137Putnam County0
139Richland County3
141Ross County1
143Sandusky County2
145Scioto County2
147Seneca County2
149Shelby County1
151Stark County6
153Summit County11
155Trumbull County5
157Tuscarawas County2
159Union County1
161Van Wert County2
163Vinton County0
165Warren County2
167Washington County2
169Wayne County2
171Williams County2
173Wood County1
175Wyandot County1
3 REPLIES 3
Stu_SAS
SAS Employee

Hey @10134458! Here's how you can do it:

  1. Look up the county ID from mapsgfk.us_counties_attr and attach it to your dataset
  2. Add a hover-over HTML variable in the format needed by PROC GMAP
  3. Create your PROC GMAP code and use the HTML option in the CHORO statement.

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;

Stu_SAS_0-1732307260434.png

 

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

 

 

 

10134458
Calcite | Level 5

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. 

sas-innovate-white.png

Missed SAS Innovate in Orlando?

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.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 617 views
  • 1 like
  • 3 in conversation