Some experiments with the code provided in the docs of proc sgmap, see https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grmapref/n0j38r5ljpv8ntn1b6e5vxwc1yyl.htm for details. Tried to add a tooltip for the bubbles show the actual population of that city. Unfortunately the population is shown for Reno only. I changed the following lines in the example:
/* changed html to html5 */
ODS HTML5 path=odsout body="&name..html" style=my_map ;
/* added imagemap */
ods graphics / imagefmt=png imagename="&name" imagemap;
/* Added "tip= (population_city)" in the bubble statement */
proc sgmap
mapdata=nevada /* Map polygon geometry */
maprespdata=county_pop /* Map polygon response data */
plotdata=city_pop /* Bubble response & location data */
;
choromap group / mapid=county id=county name='counties';
bubble x=long y=lat size=population_city /
fillattrs=(color=yellow)
name='cities'
datalabel=city datalabelattrs= (color=black size=9 style=italic)
tip= (population_city);
keylegend 'counties' / title='County Population';
keylegend 'cities' / title='City Population';
run;
Mouse pointer disappeared when i took the screenshot, but was in the middle of the yellow Las Vegas bubble:
Any ideas on how to fix this?
Using SAS 9.4m7 on Windoze.
Are you getting any messages in your SAS log regarding the tip= ?
Unfortunately not, here is the log:
27 %let name=sgmpnvb2; 28 filename odsout "Ausgabe"; 29 30 ods path(prepend) work.templat(update); 31 proc template; 32 define style my_map; 33 parent=styles.htmlblue; 34 class graphcolors / 35 "gdata1" = cx3182bd 36 "gdata2" = cx6baed6 37 "gdata3" = cx9ecae1 38 "gdata4" = cxc6dbef 39 "gdata5" = cxeff3ff; 40 end; NOTE: Overwriting existing template/link: My_map NOTE: STYLE 'My_map' has been saved to: WORK.TEMPLAT 41 run; NOTE: Verwendet wurde: PROZEDUR TEMPLATE - (Gesamtverarbeitungszeit): real time 0.00 seconds cpu time 0.00 seconds 42 43 ODS HTML5 path=odsout body="&name..html" style=my_map ; NOTE: Writing HTML5 Body file: sgmpnvb2.html 44 45 ods graphics / imagefmt=png imagename="&name" imagemap; 46 47 data city_pop (label='Nevada County Seat Populations'); 48 length city $65; 49 infile datalines dlm=','; 50 input city population_city county; 51 state='NV'; 52 datalines; NOTE: The data set WORK.CITY_POP has 17 observations and 4 variables. NOTE: Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit): real time 0.00 seconds cpu time 0.00 seconds 70 ; 71 run; 72 73 proc geocode 74 method=city 75 data=city_pop 76 out=city_pop (rename=(x=long y=lat)) 77 lookupcity=sashelp.zipcode; /* Use this if you don't have SAS GRAPH */ 78 run; NOTE: Address data set had only 17 observations. Intermediate progress times not output. _________ Geocoding Summary _____________________________ Address data: WORK.CITY_POP Output data: WORK.CITY_POP CITY lookup data: SASHELP.ZIPCODE Geocoding method: City & state Run date: 26Nov2021 Obs processed: 17 Elapsed time: 00:00:00 Obs per minute: 1,020,000 City matches: 17 Not matched: 0 _________________________________________________________ NOTE: Verwendet wurde: PROZEDUR GEOCODE - (Gesamtverarbeitungszeit): real time 0.01 seconds cpu time 0.01 seconds 79 80 data county_pop (label='Nevada Counties'); 81 length county_name $55; 82 infile datalines dlm=','; 83 input county_name county population_county; 84 85 statecode = 'NV'; 86 /* Add five population ranges as groups to map response data. */ 87 if population_county > 100000 then group='Greater than 100,000'; 88 else if population_county > 10000 then group='10,000 - 100,000'; 89 else if population_county > 5000 then group='5,000 - 10,000'; 90 else if population_county > 1000 then group='1,000 - 5,000'; 91 else group='Less than 1,000'; 92 93 datalines; NOTE: The data set WORK.COUNTY_POP has 17 observations and 5 variables. NOTE: Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit): real time 0.00 seconds cpu time 0.00 seconds 111 ; 112 run; 113 114 proc sort data=county_pop; 115 by descending population_county; 116 run; NOTE: There were 17 observations read from the data set WORK.COUNTY_POP. NOTE: The data set WORK.COUNTY_POP has 17 observations and 5 variables. NOTE: Verwendet wurde: PROZEDUR SORT - (Gesamtverarbeitungszeit): real time 0.01 seconds cpu time 0.01 seconds 117 118 data nevada; 119 set mapsgfk.us_counties(where=(statecode='NV')); 120 run; NOTE: There were 3390 observations read from the data set MAPSGFK.US_COUNTIES. WHERE statecode='NV'; NOTE: The data set WORK.NEVADA has 3390 observations and 13 variables. NOTE: Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit): real time 0.07 seconds cpu time 0.06 seconds 121 122 title 'Nevada County Seats and Populations'; 123 124 proc sgmap 125 mapdata=nevada /* Map polygon geometry */ 126 maprespdata=county_pop /* Map polygon response data */ 127 plotdata=city_pop /* Bubble response & location data */ 128 ; 129 choromap group / mapid=county id=county name='counties'; 130 bubble x=long y=lat size=population_city / 131 fillattrs=(color=yellow) 132 name='cities' 133 datalabel=city datalabelattrs= (color=black size=9 style=italic) 134 tip= (population_city); 135 keylegend 'counties' / title='County Population'; 136 keylegend 'cities' / title='City Population'; 137 run; NOTE: Choromap boundaries drawn using LAT and LONG from map data set WORK.NEVADA. NOTE: Verwendet wurde: PROZEDUR SGMAP - (Gesamtverarbeitungszeit): real time 2.84 seconds cpu time 0.14 seconds NOTE: There were 17 observations read from the data set WORK.COUNTY_POP. NOTE: There were 17 observations read from the data set WORK.CITY_POP. 138 139 ods html5 close;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.