Data visualization with SAS programming

colors of bars sgpanel

Reply
Occasional Contributor
Posts: 8

colors of bars sgpanel

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;


Rel_Frequencia.JPG
Grand Advisor
Posts: 10,241

Re: colors of bars sgpanel

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?

Occasional Contributor
Posts: 8

Re: colors of bars sgpanel

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

SAS Super FREQ
Posts: 890

Re: colors of bars sgpanel

What version of SAS are you using?

Occasional Contributor
Posts: 8

Re: colors of bars sgpanel

9.2

SAS Super FREQ
Posts: 890

Re: colors of bars sgpanel

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;

Occasional Contributor
Posts: 8

Re: colors of bars sgpanel

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?

Ask a Question
Discussion stats
  • 6 replies
  • 525 views
  • 8 likes
  • 3 in conversation