Programming the statistical procedures from SAS

Horizontal boxplot & cboxfill

Reply
Contributor
Posts: 33

Horizontal boxplot & cboxfill

Hello!
In v 9.2 you can make a horizontal boxplot if you use ods graphics. I am trying to change the color of the boxes, with the option cboxfill. But it doesn´t work. I works fine without ods graphics, but then the plot become vertical. Do I have to change in some templates or something to get the fill colour to be right?

example:
data temp;
input id growth light temp;
cards;
1 4.55 1 1
2 4.24 1 1
3 4.89 1 2
4 4.88 1 2
5 5.01 1 3
6 5.11 1 3
7 5.55 2 1
8 4.08 2 1
9 6.09 2 2
10 5.01 2 2
11 7.01 2 3
12 6.92 2 3
;
run;
*2. Dictionary of variable values for readability;
proc format;
value lightf 1='1=low'
2='2=high';
value tempf 1='1=cold'
2='2=lukewarm'
3='3=warm';
run;
quit;

proc sort data=temp;
by temp;
run;

ods graphics on;
proc boxplot data=temp;
plot growth*temp
/boxstyle=skeletal
horizontal
cboxes=cx153e7e
cboxfill=red;
title 'Fish Growth by Temperature';
format temp tempf.;
run;
ods graphics off;

tks for advice
Br Jenny
SAS Super FREQ
Posts: 8,679

Re: Horizontal boxplot & cboxfill

Hi:
It says in the BOXPLOT documentation, that if you use ODS GRAPHICS with PROC BOXPLOT, that:
"PLOT statement options used to control the appearance of traditional high-resolution graphs are ignored for ODS Graphics output. "


Doc is here:
http://support.sas.com/documentation/cdl/en/statug/59654/HTML/default/statug_boxplot_sect024.htm

This means that options like CBOXFILL won't work for you. So, if you want to change the fill color, you would have to make a style template change. It is the GraphDataDefault style element that controls the default fill color. In the template below, all of the style attributes will come from the SASWEB style, except for GraphDataDefault color attribute, which has been set to red. Then, the changed template is used, in this example, for ODS HTML.

cynthia

[pre]
ods path work.mytemplt(update)
sasuser.templat(update)
sashelp.tmplmst(read);

proc template;
define style styles.special;
parent=styles.sasweb;
class GraphDataDefault /
color = red;
end;
run;

ods html path='.' gpath='.'
file='hboxplot5.html' style=styles.special;
... your code...
ods html close;
[/pre]
Contributor
Posts: 33

Re: Horizontal boxplot & cboxfill

awesome. thank you so much, cynthia! This saved a lot of time for me.

Have a nice summer
Br
Jenny
Contributor
Posts: 33

Re: Horizontal boxplot & cboxfill

.
Occasional Contributor
Posts: 16

Re: Horizontal boxplot & cboxfill

My experiment arranged in Split Plot design. How to make a Charts/ Boxplots for Proportions of a Binary Variable ?

data Survival;

  input A $ B $ Block Y;  if Y=1 then 1='Survive'; else 0='Died';

datalines;

A1     B1     1      0

A1     B1     2      1

A1     B1     3      0

A1     B1     4      0

A1     B1     5      0

A1     B2     1      1

A1     B2     2      1

A1     B2     3      1

A1     B2     4      1

A1     B2     5      0

A1     B3     1      1

A1     B3     2      0

A1     B3     3      0

A1     B3     4      1

A1     B3     5      1

A2     B1     1      0

A2     B1     2      0

A2     B1     3      0

A2     B1     4      0

A2     B1     5      0

A2     B2     1      1

A2     B2     2      0

A2     B2     3      0

A2     B2     4      1

A2     B2     5      0

A2     B3     1      1

A2     B3     2      1

A2     B3     3      1

A2     B3     4      0

A2     B3     5      1

A3     B1     1      1

A3     B1     2      0

A3     B1     3      1

A3     B1     4      0

A3     B1     5      0

A3     B2     1      0

A3     B2     2      1

A3     B2     3      1

A3     B2     4      1

A3     B2     5      0

A3     B3     1      0

A3     B3     2      1

A3     B3     3      0

A3     B3     4      1

A3     B3     5      1

;

 

Is it true when it displayed in as shown below ? how to write the codes?

 

original.jpg

 

 

Please help me it is so important for me...

Ask a Question
Discussion stats
  • 4 replies
  • 519 views
  • 0 likes
  • 3 in conversation