BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
A_Kh
Lapis Lazuli | Level 10

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
Or for your this special case. Try options SPARSE :
tables type*cylinders/out=have totpct outpct;

-->
tables type*cylinders/out=have totpct outpct sparse;

View solution in original post

4 REPLIES 4
A_Kh
Lapis Lazuli | Level 10

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!!

Ksharp
Super User
Or for your this special case. Try options SPARSE :
tables type*cylinders/out=have totpct outpct;

-->
tables type*cylinders/out=have totpct outpct sparse;

A_Kh
Lapis Lazuli | Level 10

Thank you so much, it works perfectly!

And the most efficient way.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

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. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 323 views
  • 7 likes
  • 3 in conversation