I am using this macrotised code:
%macro PlotMacro(Title, Footnote, X, Y, Z);
title &Title.;
proc sgplot data=SomeData
noautolegend;
bubble X = &X. Y = &Y. size= &Z. /
transparency=0.4 datalabelattrs=(size=9 weight=bold);
run;
%mend;
Is there a way to color the bubbles according to a 'group/class' column in SomeData.
Use the GROUP= option in the bubble statement after the / as in this very simple example
title "Bubble plot by Sex";
proc sgplot data=sashelp.class noautolegend;
bubble x=height y=weight size=age / group=sex;
run;
Also, why do you use a macro to do this? It just seems like more typing to me.
Use the GROUP= option in the bubble statement after the / as in this very simple example
title "Bubble plot by Sex";
proc sgplot data=sashelp.class noautolegend;
bubble x=height y=weight size=age / group=sex;
run;
Also, why do you use a macro to do this? It just seems like more typing to me.
Hi,
There is a group option in the Bubble statement. I believe you can use that to color the bubbles, i.e. group=column (in Somedata)
Many thanks,
Kriss
The bubble plot supports the group option which will color the bubbles based on a character variable. It also supports the color response option which will color the bubbles based on a numeric variable.
Something like in this example?
title "Bubble plot by Sex";
proc sgplot data=sashelp.class noautolegend;
bubble x=height y=weight size=age / group=sex;
keylegend / position=nw location=inside across=1;
run;
The sgplot procedure will automatically create a legend based on the group variable. Remove the no auto legend from your program, and you should then see the legend.
Thanks
Scott
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.
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.