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

Hello SAS users,

I'm trying to change the colour of this bubble plot to have different colors for different sizes and add a label.

 

This is my code for the plot:

proc sgmap plotdata=belluno2;
openstreetmap;
where lon > 10.435428 and lat > 44.847916 and lat < 46.731138;
bubble x=lon y=lat size=f /group=source bradiusmin=0.2 fillattrs=(transparency=.4); 
keylegend;
run;

And this is the output:

img0.png

My goal is to replicate/have something similar to the graph here below (made with R), where the color gets lighter when the frequency gets bigger and a label where i can see the size of the bubble beside the frequency.  

 

 

5f47052b-4815-4d4e-9246-c4ea91180afc.png

Is it possible? 

Thank you a lot!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Changing color with the value of a response variable is amazingly enough COLORESPONSE coupled with COLORMODEL

 

There is an example here: https://support.sas.com/kb/68/115.html

that shows using a continuous bar with the meaning of the response color

Since you apparently want a darker color associated with the smaller value of your response variable then you might want

 

colormodel=(darkblue lightblue)

 

I would recommend the GRADLEGEND (gradient legend) as it shows a continuous value so people can interpret color shades a bit more accurately than discrete bubbles

View solution in original post

4 REPLIES 4
ballardw
Super User

Changing color with the value of a response variable is amazingly enough COLORESPONSE coupled with COLORMODEL

 

There is an example here: https://support.sas.com/kb/68/115.html

that shows using a continuous bar with the meaning of the response color

Since you apparently want a darker color associated with the smaller value of your response variable then you might want

 

colormodel=(darkblue lightblue)

 

I would recommend the GRADLEGEND (gradient legend) as it shows a continuous value so people can interpret color shades a bit more accurately than discrete bubbles

veronicasalmaso
Obsidian | Level 7

When I enter the code for colorresponse and colormodel, the following error apperars:

Syntax error, expecting one of the following: ;, BRADIUSMAX, BRADIUSMIN, CM, DATALABEL, DATALABELATTRS,
DATALABELPOS, FILL, FILLATTRS, GROUP, IN, LEGENDLABEL, MM, NAME, NOFILL, NOMISSINGGROUP, OUTLINE, PCT, PT, PX,
TRANSPARENCY.

I'm using SAS 9.4M6 release, is there anything I can try for this release?

ballardw
Super User

ANY time that you have a question about an error please copy the code and all the warnings, notes, errors and messages from the log for the step with the error. On the forum open a text box using the </> icon above the message window and paste the text. The entire procedure or data step, not just the line that causes the error.

 

The text box is important because frequently SAS provides diagnostic characters indicating where the problem was detected and the main message windows in the forum software will reformat pasted text reducing the usefulness of the diagnostics. The entire procedure or data step because the cause might be a missing ; on a previous statement, missing a ( or ) or similar elsewhere in the code.

veronicasalmaso
Obsidian | Level 7
Got it! I'll keep it in mind for the future. The code is correct, colorresponse and colormodel don't work because I'm using a release where they probably weren't added yet, since in the link with the example it's written that release 9.4M7 is needed

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 4 replies
  • 1033 views
  • 2 likes
  • 2 in conversation