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.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.