Hello Community,
My group values are not getting consistently colored across all groups. I found a similar topic with PROC SGPLOT where @djrisks gave a solution using Discrete Attribute Maps method. I'm wondering if this technique works for SGPANEL as well or there are different ways to get consistent colors by group values.
For clarity I used the below code (where 'yellow' represents Cylinders=10 in SUV group and Cylinders=12 in Sports group. I need 'yellow' to represent only Cylinders=10).
proc sort data=sashelp.cars out=cars; by origin type; run;
proc freq data=cars;
where cylinders in (4 5 6 8 10 12);
by origin;
tables type*cylinders/out=have totpct outpct;
run;
title 'SUV cars';
proc SGPANEL data=have;
where type eq "SUV";
panelby origin;
styleattrs datacolors=(blue red green yellow orange purple);
vbar type / response=pct_row group=cylinders groupdisplay=stack;
colaxis discreteorder=data valueattrs=(size=7pt) fitpolicy=rotate label="Cylinders";;
rowaxis grid values=(0 to 100 by 10) label="Percent";
run;
title 'Sports cars';
proc SGPANEL data=have;
where type eq "Sports";
panelby origin;
styleattrs datacolors=(blue red green yellow orange purple);
vbar type / response=pct_row group=cylinders groupdisplay=stack;
colaxis discreteorder=data valueattrs=(size=7pt) fitpolicy=rotate label="Cylinders";;
rowaxis grid values=(0 to 100 by 10) label="Percent";
run;
title;
Any help much appreciated.
Thank you!
Use discrete attribute maps.
https://www.lexjansen.com/sesug/2021/SESUG2021_Paper_77_Final_PDF.pdf
https://support.sas.com/resources/papers/proceedings19/3794-2019.pdf
Thank you for the quick reply and tips!
As documentation focused on SGPLOT procedure, I couldn't replicate it in my SGPANEL.. But appreciate sharing those info with me!!
Thank you so much, it works perfectly!
And the most efficient way.
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.