BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
dac_js
Quartz | Level 8

I am using PROC GMAP for the first time. I need help with changing the way the legends (the 3 levels in the example) are shown in the map.

For example when I am creating a sample US state map in the following way SAS is using three separate levels of colors. Changing the LEVELS = option I can get more levels but the same issue exists. Is there any way to show the density_2020 by different state  as a range of 0 to 10,000. (The map should not change only I am trying to show the legends in a different way)

 

 

proc gmap data=sashelp.us_data map=mapssas.us;
id state;
choro density_2010 / levels=3 legend=legend1;
run;
quit;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Check @Rick_SAS blog :

 

https://blogs.sas.com/content/iml/2015/11/18/create-a-map-with-proc-sgplot.html

 

data US;
   set maps.US;
  * where StateCode NOT IN ("AK", "HI", "PR");
   by State Segment;
   if first.Segment then PolyID+1;    /* create ID variable for polygons */
run;

 
title "US States with Some Large Cities";
proc sgplot data=us ;
   polygon x=x y=y ID=PolyID / fill outline group=StateCode colorresponse=PolyID colormodel=(verylightblue verydarkblue);
   xaxis display=none;
   yaxis display=none;
run;

Ksharp_0-1670227594165.png

 

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

Use the MIDPOINTS and RANGE option

 

proc gmap data=sashelp.us_data map=mapssas.us;
id state;
choro density_2010 / levels=3 midpoints=100 200 500 range;
run;
quit;
--
Paige Miller
dac_js
Quartz | Level 8

Thank you very much for your help! Is it possible to get the legend in a format like the attached map?  

Picture1.png

 

Ksharp
Super User

Check @Rick_SAS blog :

 

https://blogs.sas.com/content/iml/2015/11/18/create-a-map-with-proc-sgplot.html

 

data US;
   set maps.US;
  * where StateCode NOT IN ("AK", "HI", "PR");
   by State Segment;
   if first.Segment then PolyID+1;    /* create ID variable for polygons */
run;

 
title "US States with Some Large Cities";
proc sgplot data=us ;
   polygon x=x y=y ID=PolyID / fill outline group=StateCode colorresponse=PolyID colormodel=(verylightblue verydarkblue);
   xaxis display=none;
   yaxis display=none;
run;

Ksharp_0-1670227594165.png

 

dac_js
Quartz | Level 8
Thank you very much!
ballardw
Super User

Please read your initial post carefully. You say "the same issue exists" but do not state what the "issue" is.

 


@dac_js wrote:

I am using PROC GMAP for the first time. I need help with changing the way the legends (the 3 levels in the example) are shown in the map.

For example when I am creating a sample US state map in the following way SAS is using three separate levels of colors. Changing the LEVELS = option I can get more levels but the same issue exists. Is there any way to show the density_2020 by different state  as a range of 0 to 10,000. (The map should not change only I am trying to show the legends in a different way)

 

 

proc gmap data=sashelp.us_data map=mapssas.us;
id state;
choro density_2010 / levels=3 legend=legend1;
run;
quit;

 


 

dac_js
Quartz | Level 8

I was looking for a way to get the legend as a scale instead of separate data points. I should have clarified that.

 

Thank you for the help!

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2191 views
  • 0 likes
  • 4 in conversation