BookmarkSubscribeRSS Feed
BenConner
Pyrite | Level 9

Hi,

 

A coworker of mine is trying to shift gmap output to the left so he can position a legend on the right.  He's using annotate for the legend and would like to be able to have the map take 60-65% of the space to the left, leaving room for the vertical legend.  Right now the sample code looks like:

 

goptions gunit=pt htitle=14 htext=8 ftitle="arial" ftext="arial/bold" cback='white';

 

legend1 across=1 origin=(80 pct, 30 pct) mode=share label=none value=("Less than 10%" "Between 10% and 25%" "25% or More") shape=bar(20pt,10pt);

 

data annolabel;

      length function $ 8;

      retain flag 0 xsys ysys '3' hsys '3' when 'a' function 'label' position '6';

      format text $52.;

      text="Low Diabetes Prevalence";

            size=2.3; x=80; y=42;

      output;

      text="% of County's Members in Plan";

            size=2; x=85; y=40;

      output;

run;

 

pattern1 color=CXfffacd; pattern2 color=CXfff59b; pattern3 color=CXFFE705;

proc gmap data=county_map_mcp3 map=county_map_mcp3 anno=annolabel gout=map1;

      title "Prevalence of Members with Diabetes: &PLAN";

      id county;

      where MCP_Name="Buckeye";

      choro bin1 / discrete legend=legend1;

run;

 

These will likely be going to RTF output.

Any suggestions?

 

Thanks!

 

--Ben


sample.PNG
4 REPLIES 4
ballardw
Super User

Don't use MODE=share in the legend statement, use MODE=RESERVE

or Position=(Middle Right Outside) in the legend statement

BenConner
Pyrite | Level 9
Hi Ballard,

The coworker who was working on this project decided to circumvent it by dropping the legend and creating an artificial one using the ODS layout facility. That gave him the control over the page he was looking for. Some clients are pickier than others at times. 🙂

Thanks!

--Ben
GraphGuy
Meteorite | Level 14

Ben - glad you found a work-around!

 

If you're curious about how to do it totally within SAS/Graph, here's the trick I use...

 

When I need extra space to the side of a graph/map/etc, I use an extra title statement, and 'angle' it so it shows up to the side of the graph (rather than above the graph). I make the height of the text the amount of space I want (such as height=40pct), and then I make the text of the title 'blank' (so no text shows up - just the blank white-space).

 

For your example, I used:

 

title2 angle=-90 height=40pct ' ';

 

And then with the extra space, I was able to make the 'origin' (start location) of the legend a little farther left  ...   origin=(70 pct, 30 pct)

 

And then I adjusted the x/y coordinates for your custom annotated legend title slightly.

 

I modified your program to work with a blank Ohio map (since I don't have your response data) to demonstrate:

 

 

goptions gunit=pt htitle=14 htext=8 ftitle="arial" ftext="arial/bold" cback='white';

legend1 across=1 origin=(70 pct, 30 pct) mode=share label=none
value=("Less than 10%" "Between 10% and 25%" "25% or More") shape=bar(20pt,10pt);

data annolabel;
length function $ 8;
retain flag 0 xsys ysys '3' hsys '3' when 'a' function 'label' position '6';
format text $52.;
text="Low Diabetes Prevalence";
size=2.3; x=70; y=43;
output;
text="% of County's Members in Plan";
size=2; x=70; y=40;
output;
run;

data county_map_mcp3; set maps.uscounty (where=(fipstate(state)='OH'));
run;

pattern1 color=CXfffacd; pattern2 color=CXfff59b; pattern3 color=CXFFE705;
proc gmap data=county_map_mcp3 map=county_map_mcp3 anno=annolabel gout=map1;
title1 "Prevalence of Members with Diabetes: &PLAN";
title2 angle=-90 height=40pct ' ';
id county;
/*where MCP_Name="Buckeye";*/
choro /*bin1*/ county / /*discrete*/ levels=3 legend=legend1;
run;

 

 

map_legend.png

 

 

BenConner
Pyrite | Level 9

Well that's slick.  I like it!   I will keep that in mind when I am asked again how to get stuff to appear on the right side.  That is a lot less work than what my coworker ended up doing.

 

Thanks!!

 

--Ben

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 4 replies
  • 1140 views
  • 0 likes
  • 3 in conversation