BookmarkSubscribeRSS Feed
young_spruce
Fluorite | Level 6

Hi,

I'm trying to create a legend that shows the name of a municipality and a number. That number should correspond to an anno on the map. I've found an example on this forum but I can't seem to recreate it.

 

Link to original post 

 

I keep running into the errors:
WARNING: Specified placement options have caused legend to extend beyond the device boundaries.
WARNING: The legend has been suppressed.

 


My code:

*gemiddelde coordinaten per gemeente;
proc sql;
create table gem_cor as
select distinct t1.gemeente, t1.kantoor, avg(t1.x) as x, avg(t1.y) as y
from kaartgemeente as t1
group by t1.gemeente
order by kantoor, gemeente
;
quit;

data gem_cor2;
set gem_cor;
by kantoor gemeente;
if first.kantoor then nr=1;
else nr+1;
run;

proc sql noprint;
select catt('j=l "',nr,': ',gemeente,'"') into :gemeente separated by ' ' from gem_cor2;
quit;

*******************************************************
kaartcode ha
*******************************************************;


*variabelen die van toepassing zijn op de kaart;
FILENAME odsout "&outpath\kaart_ha";
goptions reset=all transparency device=png gsfname=odsout gsfmode=replace xpixels=1200 ypixels=1000 nofileonly;
ODS LISTING CLOSE;
ods listing;

*kleuren achtergrond van stedelijkheid bepalen;
pattern1 value=solid color='CXeff3ff'; ****super lichtblauw****;
pattern2 value=solid color='CXbdd7e7'; ****lichtblauw****;
pattern3 value=solid color='CX6baed6'; ****licht donkerblauw****;
pattern4 value=solid color='CX3182bd'; ****donkerblauw****;
pattern5 value=solid color='CX08519c'; ****super donkerblauw****;




data anno_labels;
set gem_cor2;
xsys='2';
ysys='2';
hsys='3';
when='a';
function='label';
size=1.1;
style = "'Albany AMT/bold'";
POSITION='5';
color='black';
text=cat(nr);
where kantoor=upcase("ZWOLLE");
;run;




proc gmap data=vv_geenbh10 map=kaartgemeente anno=anno_labels;
where regio="ZWOLLE";
id gemeente;
choro ratio/

coutline='CX002857'
legend=legend1
name="vv_ZWOLLE_ha"
statistic=first
Cdef='white'
;

legend1 origin=(3,20)pct mode=share
value=none shape=bar(.00001,.00001)pct label=(&gemeente);

run;



proc greplay igout=work.listing;
delete _ALL_;

proc greplay igout=work.gseg;
delete _ALL_;

ods listing close;

 

3 REPLIES 3
ballardw
Super User

What does your LOG show when you run the Gmap code? If you are getting any Notes, Warnings or Errors you  should copy the text of the Proc Gmap along with all the notes, open a text box on the forum using the </> icon above the message box and paste all the log text. All the code an text.

 

The specific warning are related to setting for your Legend requesting coordinates that are outside the range of the display. The units associated with a Legend origin should be inside the parentheses:

legend1 origin=(3 pct,20 pct) mode=share

I think that if the units are not inside then the default becomes the GUNITS setting value.

 

One common problem is having a different coordinate system in your annotate data set or legend than the map data set uses. If you see a note in the log about value outside the range of the map that may be the problem.

Another possibility is that you have no annotate points inside the map shown with the Where regio="ZWOLLE" displayed.

 

Without your map and annotate data sets it is hard to be specific.

 

 

GraphGuy
Meteorite | Level 14

Not really knowing what your map looks like, or what other settings are in effect when you run it (eg, what font sizes, or how long the legend text is, etc), I'll just try to give some advice that will get you past the warnings, and at least show a legend (maybe not quite the legend you want ... but at least a starting point).

 

Perhaps the legend text values are too long to fit in the graph area, or perhaps the text is in a large font which makes it extend outside the graph area. Or, perhaps the legend origin position is causing a problem.

 

Perhaps if you try something like this instead of the legend statement you're currently using, it will create a legend with very small text font, that will fit in the graph area and not trigger the warning that suppresses the legend (I'm writing these options from memory - they might need some fine-tuning!) ...

 

goptions htext=5pt;

legend1 position=(top left) across=1 mode=share;

 

 

young_spruce
Fluorite | Level 6

Hi both,

 

Thanks for the quick reply's. I recently changed laptops so my reply is a bit later than I hoped. 

 

Both of your answers helped solve the issues, thanks!

There were two problems:

1. The dataset had the identifier formatted as a character variable with a length of 200. I changed that to the actual max.

2. The macro variable data contained more data than just kantoor=upcase("ZWOLLE"). The code now filters that macro variable to only contain the options used in the map.

 

Below is my earlier code edited to a working version for other people interested.

The added code is bold and underlined. I have also added a map as an example. Note that the formatting on that map is different from the formatting in the code below.

 

 

*gemiddelde coordinaten per gemeente;
proc sql;
create table gem_cor as
select distinct t1.gemeente, t1.kantoor, avg(t1.x) as x, avg(t1.y) as y
from kaartgemeente as t1
group by t1.gemeente
order by kantoor, gemeente
;
quit;

data gem_cor2;
set gem_cor;
by kantoor gemeente;
if first.kantoor then nr=1;
else nr+1;
run;

proc sql noprint;
select catt('j=l "',nr,': ',gemeente,'"') into :gemeente separated by ' ' from gem_cor2
where kantoor=upcase("ZWOLLE");
quit; ******************************************************* kaartcode ha *******************************************************; *variabelen die van toepassing zijn op de kaart; FILENAME odsout "&outpath\kaart_ha"; goptions reset=all transparency device=png gsfname=odsout gsfmode=replace xpixels=1200 ypixels=1000 nofileonly; ODS LISTING CLOSE; ods listing; *kleuren achtergrond van stedelijkheid bepalen; pattern1 value=solid color='CXeff3ff'; ****super lichtblauw****; pattern2 value=solid color='CXbdd7e7'; ****lichtblauw****; pattern3 value=solid color='CX6baed6'; ****licht donkerblauw****; pattern4 value=solid color='CX3182bd'; ****donkerblauw****; pattern5 value=solid color='CX08519c'; ****super donkerblauw****; data anno_labels; set gem_cor2; xsys='2'; ysys='2'; hsys='3'; when='a'; function='label'; size=1.1; style = "'Albany AMT/bold'"; POSITION='5'; color='black'; text=cat(nr); where kantoor=upcase("ZWOLLE"); ;run; proc gmap data=vv_geenbh10 map=kaartgemeente anno=anno_labels; where regio="ZWOLLE"; id gemeente; choro ratio/ coutline='CX002857' legend=legend1 name="vv_ZWOLLE_ha" statistic=first Cdef='white' ; legend1 origin=(3,20)pct mode=share value=none shape=bar(.00001,.00001)pct label=(&gemeente); run; proc greplay igout=work.listing; delete _ALL_; proc greplay igout=work.gseg; delete _ALL_; ods listing close;

This is my final mapThis is my final map

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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
  • 3 replies
  • 618 views
  • 3 likes
  • 3 in conversation