Hi All
I am trying to produce boxplot using SAS GTL and ended up getting the following message in the log
"WARNING: The data for boxes is incomplete or invalid. Some boxes will not be drawn."
Can someone help me how to get rid of this warning message!
Thanks
John
TRTA | TRTAN | AVAL |
A | 1 | 5.265563 |
A | 1 | 2.416991 |
A | 1 | 6.361984 |
A | 1 | 2.733437 |
A | 1 | 4.215147 |
A | 1 | 4.298788 |
A | 1 | 3.76999 |
A | 1 | 3.447105 |
A | 1 | 3.17307 |
A | 1 | 4.58969 |
A | 1 | 5.020884 |
A | 1 | 5.169635 |
A | 1 | 2.244204 |
A | 1 | 2.13761 |
A | 1 | 2.61073 |
A | 1 | 2.964504 |
A | 1 | 3.140009 |
A | 1 | 5.143698 |
A | 1 | 4.861378 |
A | 1 | 3.838215 |
A | 1 | 2.769648 |
A | 1 | 3.704952 |
B | 2 | 3.105561 |
B | 2 | 2.574498 |
B | 2 | 6.451404 |
B | 2 | 3.030039 |
B | 2 | 2.99401 |
B | 2 | 4.847858 |
B | 2 | 3.997044 |
B | 2 | 2.420613 |
B | 2 | 5.188032 |
B | 2 | 3.510903 |
B | 2 | 3.144169 |
B | 2 | 3.79773 |
B | 2 | 3.302072 |
B | 2 | 2.952558 |
proc template;
define statgraph box;
begingraph/ designwidth=9.3in designheight=4.5in border=yes;;
entrytitle "X" / textattrs=(size=9);
layout lattice / columns=1 rows=1 columnweights=(0.7) ;
layout overlay / yaxisopts=(linearopts=(tickvaluesequence=(start=1 end=7 increment=1) viewmin=1 viewmax=7) label='X')
xaxisopts=(display=(tickvalues label) label="Treatment Group");
boxplot x=trta y=eval(ifn(trtan=1,aval, .)) / whiskerpercentile=10 display=(mean median outliers caps fill) capshape=line
discreteoffset=0 boxwidth=.27 name='a' legendlabel="A"
outlineattrs=(color=blue thickness=2) outlierattrs=(color=blue symbol=square /*trianglefilled*/)
meanattrs=(color=blue symbol=asterisk)
medianattrs=(color=blue thickness=2)
whiskerattrs=(color=blue thickness=2);
boxplot x=trta y=eval(ifn(trtan=2,aval, .)) / whiskerpercentile=10 display=(mean median outliers caps fill) capshape=line
discreteoffset=0 boxwidth=.27 name='b' legendlabel="B"
outlineattrs=(color=red thickness=2) outlierattrs=(color=red symbol=square)
meanattrs=(color=red symbol=asterisk)
medianattrs=(color=red thickness=2)
whiskerattrs=(color=red thickness=2);
endlayout;
endlayout;
endgraph;
end;
run;
proc sgrender data=adpp template=box;;
run;
You're attempting to use the ifn() expression to "where out" different category values so you treat the data as overlays instead of group data. This makes boxes with all missing values, causing the messages to be generated. It appears you're doing this to control the attributes for each box. A cleaner way to do this (which will also eliminate your messages) is to remove the ifn()'s and use attributes maps instead. That way, you can control the attributes for each group. If you need more information on attribute maps, look in this paper I wrote back in 2014: http://support.sas.com/resources/papers/proceedings14/SAS156-2014.pdf.
Hope this helps!
Dan
Using the data from your example, the code for the solution I proposed is below. I used an attrmap data set instead of putting the attrmap directly in the template, as it gives you more flexibility and re-use for other templates you might use for rendering the same treatment groups.
data attrmap;
retain id "trtgrp";
length linecolor $ 4;
input value $ linecolor $;
cards;
A blue
B red
;
run;
proc template;
define statgraph box;
begingraph/ designwidth=9.3in designheight=4.5in border=yes;;
entrytitle "X" / textattrs=(size=9);
layout lattice / columns=1 rows=1 columnweights=(0.7) ;
layout overlay / yaxisopts=(linearopts=(tickvaluesequence=(start=1 end=7 increment=1) viewmin=1 viewmax=7) label='X')
xaxisopts=(display=(tickvalues label) label="Treatment Group");
boxplot x=trta y=aval / whiskerpercentile=10 display=(mean median outliers caps fill) capshape=line
name='a' outlineattrs=(thickness=2) outlierattrs=(symbol=square /*trianglefilled*/) group=TRTA
groupdisplay=cluster meanattrs=(symbol=asterisk) medianattrs=(thickness=2) whiskerattrs=(thickness=2);
endlayout;
endlayout;
endgraph;
end;
run;
ods html;
proc sgrender data=adpp template=box dattrmap=attrmap;
dattrvar TRTA="trtgrp";
run;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.