BookmarkSubscribeRSS Feed
Vahe_Mar
Obsidian | Level 7

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;

Thanks,
Vahe
6 REPLIES 6
PeterClemmensen
Tourmaline | Level 20

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;

 

 

Vahe_Mar
Obsidian | Level 7
this is changing both
Thanks,
Vahe
PeterClemmensen
Tourmaline | Level 20

Both what? What do you want to change?

Vahe_Mar
Obsidian | Level 7
SAS giving automatically two colours blue and red, so i want change colours firs red after blue
Thanks,
Vahe
DR_Majeti
Quartz | Level 8

Hi, 

 

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

Rick_SAS
SAS Super FREQ

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...

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 978 views
  • 1 like
  • 4 in conversation