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 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 963 views
  • 0 likes
  • 2 in conversation