BookmarkSubscribeRSS Feed
LuizSousa
Calcite | Level 5

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
6 REPLIES 6
ballardw
Super User

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?

LuizSousa
Calcite | Level 5

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

DanH_sas
SAS Super FREQ

What version of SAS are you using?

LuizSousa
Calcite | Level 5

9.2

DanH_sas
SAS Super FREQ

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;

LuizSousa
Calcite | Level 5

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?

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1945 views
  • 8 likes
  • 3 in conversation