Hi,
I'm using sgpanel to create the graph attached. I wonder how do I put in specific colors grouped bars.
Below is the code I am using:
data tt;
infile datalines dlm="|" dsd ;
input _name_ : $32. Nome_Grup : $CHAR56. Mensal : COMMAX16.2 COL1 : COMMAX16.2 ;
datalines;
Anual 07.2012 a 06.2013|TESTE1|0,48|5,77
Anual 07.2013 a 06.2014|TESTE1|0,38|4,59
Anual 07.2013 a 06.2014|TESTE2|0,12|1,47
Anual 07.2012 a 06.2013|TESTE2|0,10|1,17
Anual 07.2012 a 06.2013|TESTE3|0,48|5,72
Anual 07.2013 a 06.2014|TESTE3|0,37|4,38
Anual 07.2013 a 06.2014|TESTE4|2,00|23,99
Anual 07.2012 a 06.2013|TESTE4|3,09|37,09
;
run;
ods graphics / reset border width=25cm height=10cm;
title "Frequência";
proc sgpanel data=tt;
panelby Nome_Grup / layout=columnlattice onepanel colheaderpos=bottom columns=10
noborder novarname ;
vbar _name_ / response=col1 datalabel group=_name_ barwidth=1 nostatlabel name="Anual";
vbar _name_ / response=Mensal datalabel group=_name_ barwidth=1 transparency=1 ;
keylegend "Anual"/ noborder position=top;
rowaxis grid display=(nolabel) ;
colaxis display=none;
run;
Are you wanting to assign the same color for all the bars of each value of Nome_Grup? And do you want to assign a specific color or just have them the same?
Also your transparency setting for response=Mensal is currently making that part invisible. How is it supposed to appear in the final plot?
Yes, if this graph is generated by two bars group, I want to make one red and one orange to leave.
The transparent bars are to stay anyway, because the only important thing is the indicator value.
Since already thank
What version of SAS are you using?
9.2
Starting with SAS 9.3, this request become simpler. With SAS 9.2, you will have to modify the ODS style to get what you want. Based on your output, it appears you are using the "Analysis" style. The code sample below creates the modified style that changes the first two colors to be red and orange. Give that try and see if it give you what you need.
proc template;
define style styles.MyAnalysis;
parent=styles.analysis;
style GraphColors from GraphColors /
'gdata1' = red
'gdata2' = orange;
end;
run;
ods html style=myanalysis;
proc sgpanel data=sashelp.class;
panelby age;
vbar sex / response=weight group=sex stat=mean;
run;
ods html close;
Solved by parts, because I'm using a stored process and putting in Web Report Studio. The ods that you are using is the html, as I put these settings in the Results?
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.