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

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
  • 1143 views
  • 9 likes
  • 3 in conversation