BookmarkSubscribeRSS Feed
Tsievu100
Fluorite | Level 6

Hi guys,

 

i am wondering how can i change in a gmap procedure the way my regions show their values. I have a dataset which containts of 3 values: an identification variable (numeric), name of the identification variable(text) and the value (numeric). In the gmap procedure I use the id variable to create the map, but i would like to see the text variable when i put my mouse on a particular region. How can it be achieved? Please find the screen shot and the dataset attached. Below the code:

 

goptions reset=all;
data poland;
set maps.poland;
run;

data poland2;
set maps.poland2;
run;

data poland_woj;
merge poland poland2;
by id;
run;

proc sort data=poland_woj;
by wojid id;
run;

proc gremove data=poland_woj out=woj;
by wojid;
id id;
run;

proc import datafile="C:\Users\Wojtek\Downloads\ROLN_3179_XTAB_20170701180026.xlsx"
out=rolnictwo dbms=xlsx replace;
sheet="tablica";
run;

title 'Suma powierzchni użytków rolnych na przekroju województw';
proc gmap data=rolnictwo map=woj all ;
id wojid;
choro powierzchnia / statistic=sum discrete ;
run;
footnote 'Źródło: Opracowanie własne.';
quit;
title;


proc gmap sas.png
1 REPLY 1
GraphGuy
Meteorite | Level 14

Here's one way to have custom mouse-over text, containing whatever values you want to put into them, using device=png and ods html output:

 

 

%let name=map;
filename odsout '.';

goptions device=png;
goptions border;

ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm" style=htmlblue;

goptions gunit=pct ftitle="albany amt/bold" ftext="albany amt" htitle=4.0 htext=2.5;
goptions ctext=gray33;

data my_data;
length nazwa $50;
informat Powierzchnia comma8.0;
input WOJID NAZWA Powierzchnia;
datalines;
1 Dolnoslaskie 31,261
2 Kujawsko-Pomorskie 10,645
3 Lubelskie 34,052
4 Lubuskie 46,343
5 Lodzkie 10,158
6 Malopolskie 12,976
7 Mazowieckie 53,790
8 Opolskie 3,042
9 Podkarpackie 16,656
10 Podlaskie 56,528
11 Pomorskie 24,866
12 Slaskie 6,638
13 Swietokrzyskie 11,598
14 Warminsko-Mazurskie 12,768
15 Wielkopolskie 34,523
16 Zachodniopomorskie 14,887
;
run;

/* merge in the numeric id1 (so you'll have something to match with the map) */
proc sql noprint;
create table my_data as
select my_data.*, poland_attr.id1
from my_data left join mapsgfk.poland_attr
on my_data.nazwa = poland_attr.id1name;
quit; run;

/* add html mouse-over text */
data my_data; set my_data;
length my_html $300;
my_html='title='||quote(
 'WOJID: '||trim(left(WOJID))||'0d'x||
 'NAZWA: '||trim(left(NAZWA))||'0d'x||
 'Powierzchnia: '||trim(left(put(Powierzchnia,comma10.0)))
 );
run;


data my_map; set mapsgfk.poland (where=(density<=1));
run;

proc gremove data=my_map out=my_map;
by id1;
id id;
run;

legend1 label=(position=top);

title1 ls=1.5 "Poland Region Map";
proc gmap data=my_data map=my_map all;
format Powierzchnia comma10.0;
id id1;
choro Powierzchnia / levels=4 legend=legend1
 coutline=gray55 html=my_html
 des='' name="&name";
run;

quit;
ODS HTML CLOSE;
ODS LISTING;

 

poland.png 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 1 reply
  • 1469 views
  • 0 likes
  • 2 in conversation