BookmarkSubscribeRSS Feed
AAWTomHanks
Calcite | Level 5

Hi, I don't know if this is possible but I want to make my legend break the data into five sections and create the legend instead of me manually going in and looking at the data. Any insite into how to accomplish this would be greatly appreciated.

Here is an example of the gmap I use:

/*-------------------------------------------------------------------------*/

goptions reset=all dev=pdf ftext="calibri" gunit=pct cback=white;

pattern1 v=ms c=cxe4e9fc;

pattern2 v=ms c=cx7793f1;

pattern3 v=ms c=cx4068ec;

pattern4 v=ms c=cx1133a3;

pattern5 v=ms c=cx0b226d;

* legend;

legend1 across=1 origin=(75,10)pct mode=share shape=bar(2,2)pct label=(h=14pt position=top "People Count") value=(h=14pt);

proc format;

value COUNT

1 - 5 = '1 - 5'

6 - 10 = '6 - 10'

11 - 25 = '11 - 25'

26 - 100 ='26 - 100'

101 - 1100 ='101 - 1,100';

proc gmap

data=M2

map=PAzipmap all;

id ZCTA;

choro People_Count / discrete legend=LEGEND1 annotate=P;

format People_Count COUNT.;

run;

quit;

3 REPLIES 3
MikeZdeb
Rhodochrosite | Level 12

hi ... have you tried ...

choro People_Count / levels=5 annotate=P;


for example ...


* not a total state population ... just add city populations within states;

proc summary data=maps.uscity nway;

var pop;

class state;

output out=uspop (drop=_:) sum=;

run;

goptions reset=all ftext='calibri' htext=1.75 gunit=pct;

pattern1 v=ms c=cxe4e9fc;

pattern2 v=ms c=cx7793f1;

pattern3 v=ms c=cx4068ec;

pattern4 v=ms c=cx1133a3;

pattern5 v=ms c=cx0b226d;

proc gmap map=maps.us data=uspop;

id state;

choro pop / levels=5 coutline=grayaa;

format pop comma10.;

run;

quit;


five_levels.png
ballardw
Super User

Another option instead of levels is to use midpoints which will let you have a little control of the resulting group.

in your example use the midpoint of the intervals for your format

choro   / midpoints=( 2.5 7.5 18 63 600.5)

MikeZdeb
Rhodochrosite | Level 12

hi ... I'm never quite sure what I'll get with MIDPOINTS, that said ...

I'm using V9.3 and you can add the RANGE option to show the actual low-high values (results of using MIDPOINTS) in the legend, otherwise you get the midpoints

using the data set and graphics options from my previous post ...

title h=3 'LEGEND WITH RANGES (BASED ON MIDPOINTS 2.5e5 1e6 2.75e6 4e6  8e6)' ls=2;

proc gmap map=maps.us data=uspop;

id state;

choro pop / midpoints=(2.5e5 1e6 2.75e6 4e6  8e6) range coutline=grayaa;

format pop comma10.;

run;

quit;


five_midpoints.png

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 995 views
  • 9 likes
  • 3 in conversation