Hey,
I want to use FILLPATTERN in my boxplot, but I do not find the right syntax, I do not know how to use fillpattern or fillpatternattrs in proc template.
proc template;
define statgraph ohne_bahnen_abschlackbandV1;
dynamic _varY _varX _bygr;
begingraph
;
layout lattice / rowdatarange=data columndatarange=data;
layout overlay / xaxisopts=( griddisplay=off discreteopts=( tickvaluefitpolicy=splitrotate))
;
boxplot x=_varX
y=_varY
/ group=_bygr
name='box' boxwidth=0.85 display=(CAPS FILL MEDIAN outliers)
groupdisplay=Cluster clusterwidth=0.85 grouporder=ascending
;
endlayout;
sidebar / align=bottom spacefill=false;
discretelegend 'box' / opaque=true border=true halign=center valign=center displayclipped=true order=rowmajor;
endsidebar;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.class template=ohne_bahnen_abschlackbandV1;
dynamic _varY="weight" _bygr="sex" _varX="age";
run;
Thanks for your help!
1. Always post the portion of the log that contains the error.
2. Your code is correct and works at SAS 9.4M5.
3. As stated in the documentation, PATTERNATTRS= and DISPLAY=(FILLPATTERN) are 9.4M5 features. If you are running an earlier version of SAS, these options are not available.
You need to specify FILLPATTERN in the DISPLAY=(...) list. If you want a pattern that is different from the default, use the FILLPATTERNATTRS= option. For example, try this:
boxplot x=_varX y=_varY
/ group=_bygr fillpatternattrs=(pattern=L1)
name='box' boxwidth=0.85 display=(CAPS FILL FILLPATTERN MEDIAN outliers)
groupdisplay=Cluster clusterwidth=0.85 grouporder=ascending
;
Thanks for your answer, but my code doesen't work, there is a syntax error:
proc template;
define statgraph TEST1;
dynamic _varY _varX _bygr;
begingraph
;
layout lattice / rowdatarange=data columndatarange=data;
layout overlay / xaxisopts=( griddisplay=off discreteopts=( tickvaluefitpolicy=splitrotate))
;
boxplot x=_varX y=_varY
/ group=_bygr fillpatternattrs=(pattern=L1)
name='box' boxwidth=0.85 display=(CAPS FILL FILLPATTERN MEDIAN outliers)
groupdisplay=Cluster clusterwidth=0.85 grouporder=ascending
;
endlayout;
sidebar / align=bottom spacefill=false;
discretelegend 'box' / opaque=true border=true halign=center valign=center displayclipped=true order=rowmajor;
endsidebar;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.class template=TEST1;
dynamic _varY="weight" _bygr="sex" _varX="age";
run;
1. Always post the portion of the log that contains the error.
2. Your code is correct and works at SAS 9.4M5.
3. As stated in the documentation, PATTERNATTRS= and DISPLAY=(FILLPATTERN) are 9.4M5 features. If you are running an earlier version of SAS, these options are not available.
" If you are running an earlier version of SAS, these options are not available." - My Version of SAS is 9.4_M4, thanks for your help!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.