Data visualization with SAS programming

moving gmap output to the left to accommodate a legend on the right

Reply
Regular Contributor
Posts: 179

moving gmap output to the left to accommodate a legend on the right

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
Super User
Posts: 11,343

Re: moving gmap output to the left to accommodate a legend on the right

Posted in reply to BenConner

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

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

Regular Contributor
Posts: 179

Re: moving gmap output to the left to accommodate a legend on the right

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. Smiley Happy

Thanks!

--Ben
SAS Employee
Posts: 982

Re: moving gmap output to the left to accommodate a legend on the right

Posted in reply to BenConner

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

 

 

Regular Contributor
Posts: 179

Re: moving gmap output to the left to accommodate a legend on the right

Posted in reply to RobertAllison_SAS

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

Ask a Question
Discussion stats
  • 4 replies
  • 191 views
  • 0 likes
  • 3 in conversation