Hi @Ksharp Thank you for the contribution. I see you already given multiple different ( Permutation and Combination) of questions asked on this topic. I was running the code using PROC SGPLOT Inspired from the @Jay54 (https://blogs.sas.com/content/graphicallyspeaking/2017/10/30/fill-patterns/) This request looks similar to what you explained with proc template but using PROCSGPLOT. like in your output you have three box for each region. but the colors are different for each car type but patttern is same for the Region. Can we do the other way around, each Region will have one different color, and each cartype will have the same pattern across the three different regions. In my Example, I am expecting below, but its not comming as expected. Treatment A = Blue color, Age group: Young = L1 Pattern, datasymbol = Circlefilled ; Old = X1 Pattern Datasymbol = square filled; Treatment B = salmon color, Age group: Young = L1 Pattern, datasymbol = Circlefilled ; Old = X1 Pattern Datasymbol = square filled; Treatment C = Green color, Age group: Young = L1 Pattern, datasymbol = Circlefilled ; Old = X1 Pattern, Datasymbol = square filled; Legends will be as per the above assignment/ counts displayed inner axis. Can you please help. thank you very much /* Create sample dataset */
data treatment_data;
input Treatment $ AgeGroup $ Value @@;
/* Create a combined group variable for styling */
length GroupVar $20;
if Treatment='A' and AgeGroup='Young' then GroupVar='A_Young';
else if Treatment='A' and AgeGroup='Old' then GroupVar='A_Old';
else if Treatment='B' and AgeGroup='Young' then GroupVar='B_Young';
else if Treatment='B' and AgeGroup='Old' then GroupVar='B_Old';
else if Treatment='C' and AgeGroup='Young' then GroupVar='C_Young';
else if Treatment='C' and AgeGroup='Old' then GroupVar='C_Old';
datalines;
A Young 25 A Young 28 A Young 30 A Young 22 A Young 26
A Old 32 A Old 35 A Old 38 A Old 30 A Old 33
B Young 18 B Young 20 B Young 22 B Young 19 B Young 21
B Old 28 B Old 30 B Old 32 B Old 27 B Old 29
C Young 30 C Young 32 C Young 34 C Young 31 C Young 33
C Old 40 C Old 42 C Old 45 C Old 38 C Old 41
;
run;
/* Create box plot with custom styling */
ods graphics on / attrpriority=color;
ods rtf file="xx\text_color_patrn.rtf" style=mypatterns;
proc sgplot data=treatment_data;
title "Box Plot with Custom Treatment Colors and Age Patterns";
styleattrs datacolors=(lightblue salmon lightblue salmon lightgreen lightgreen )
datafillpatterns=(L1 X1)
DATASYMBOLS=( circlefilled squarefilled )
datacontrastcolors=(blue red green); /* Young=L1, Old=X1 for all treatments */
vbox Value / category=Treatment
group=AgeGroup
groupdisplay=cluster
nooutliers
fillpattern
/* fillattrs=(transparency=0.3)*/
grouporder=data;
/* Assign specific colors and patterns */
xaxis label="Treatment";
yaxis label="Measurement Value" grid;
/* Custom legend */
keylegend / title="Age Group"
position=topright
across=1;
run;
ods rtf close;
... View more