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;
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;
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)
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.