DATA Step, Macro, Functions and more

BOXPLOTS

Reply
Contributor
Posts: 38

BOXPLOTS

How to change colours in boxplot

proc template;
define statgraph classbox;
begingraph / designwidth=700px designheight=450px backgroundcolor=CXE8E6E8;
layout overlay;
boxplot y=&var1 x=tmt/group=ANALYTE_FULL name='box' ;

endlayout;
endgraph;
end;
run;

PROC Star
Posts: 1,400

Re: BOXPLOTS

Are you sure you want to do this at template level?

 

Why not just change the color directly in an SGPLOT Procedure? You can control the colors of the individual parts like this

 

proc sgplot data=sashelp.heart;
    vbox cholesterol / category=deathcause fillattrs=(color=green) 
                                           lineattrs=(color=black)
                                           whiskerattrs=(color=blue)
                                           meanattrs=(color=red)
                                           medianattrs=(color=red)
                                           outlierattrs=(color=purple);
run;

 

 

Contributor
Posts: 38

Re: BOXPLOTS

this is changing both
PROC Star
Posts: 1,400

Re: BOXPLOTS

[ Edited ]

Both what? What do you want to change?

Contributor
Posts: 38

Re: BOXPLOTS

SAS giving automatically two colours blue and red, so i want change colours firs red after blue
Contributor
Posts: 72

Re: BOXPLOTS

Hi, 

 

Please let know which part of Box need a Color update is required. 

SAS Super FREQ
Posts: 4,272

Re: BOXPLOTS

I think you are asking about changing the colors that are associated with the groups in the GROUP= option.

You can use the STLEATTRS statement to set those values. 

 

See 

https://blogs.sas.com/content/graphicallyspeaking/2013/07/14/setting-graph-colors-is-easier-with-sas...

or if you are not using SAS 9.4, see

https://blogs.sas.com/content/iml/2012/10/17/specify-the-colors-of-groups-in-sas-statistical-graphic...

 

 

Ask a Question
Discussion stats
  • 6 replies
  • 131 views
  • 1 like
  • 4 in conversation