Sample 69817: Creating panels of box plots with a highlighted area using the SGPANEL procedure with the BAND and BOX statements
This SAS Note uses the SGPANEL procedure with the BAND and BOX statements to produce panels of box plots with a highlighted area.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample code uses the SGPANEL procedure with the BAND and BOX statements to produce panels of box plots with a highlighted area.
/* --Create formats--*/
proc format;
value visitnum
1='PreRx'
2='Week 1'
3='Week 2'
4='Week 3'
5='Week 5'
6='Week 6';
/* reference the unicode values for superscript 3 and mu */
value labname
1="WBC x 10(*ESC*){Unicode '00b3'x} / (*ESC*){Unicode mu}L"
2='Neutrophils %'
run;
/*--Generate sample Labs data--*/
data labs;
format visitnum visitnum.;
do visitnum=1 to 6;
line=1;
a=0.6+0.4*ranuni(2);
do i=1 to 100;
result=a*10*ranuni(2)+2.5;
output;
end;
line=2;
a=0.6+0.4*ranuni(2);
do i=1 to 100;
result=a*40*ranuni(2)+40;
output;
end;
end;
run;
proc sort data=labs;
by line visitnum;
run;
/*--Add CCL limits--*/
data labs2;
format numlow best8. numhi best8.;
format label labname.;
set labs;
by line;
if first.line or last.line then do;
if line=1 then do; numlow= 3.8; numhi= 10.7; end;
if line=2 then do; numlow = 40.5; numhi = 75.0; end;
end;
if first.line then label=line;
run;
/*--Panel with Class labels--*/
ods graphics / reset width=600px height=400px imagefmt=png imagename='Panel_Band_Box';
title 'WBC and Differential: Weeks 1-6';
proc sgpanel data=labs2 noautolegend;
panelby line /onepanel uniscale=column layout=rowlattice noheader;
band x=visitnum lower=numlow upper=numhi / transparency=0.8
fillattrs=(color=gold) legendlabel='Limits';
refline numlow / label noclip lineattrs=(thickness=0) labelattrs=(size=8);
refline numhi / label noclip lineattrs=(thickness=0) labelattrs=(size=8);
scatter x=visitnum y=result / transparency=0.8 jitter;
vbox result / category=visitnum nofill nooutliers;
inset label / position=topleft nolabel textattrs=(size=10);
rowaxis display=(nolabel) offsetmax=0.15 valueattrs=(size=10) grid;
colaxis display=(nolabel) valueattrs=(size=10);
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> SGPANEL
|
Date Modified: | 2023-01-31 13:21:39 |
Date Created: | 2023-01-19 09:05:24 |
Operating System and Release Information
SAS System | Base SAS | z/OS | 9.4 | | 9.4 TS1M0 | |
z/OS 64-bit | 9.4 | | 9.4 TS1M0 | |
Microsoft® Windows® for x64 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 8 Enterprise x64 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 8 Pro x64 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 8.1 Enterprise 32-bit | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 8.1 Enterprise x64 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 8.1 Pro 32-bit | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 8.1 Pro x64 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows 10 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows Server 2008 R2 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows Server 2008 for x64 | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows Server 2012 Datacenter | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows Server 2012 R2 Datacenter | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows Server 2012 R2 Std | 9.4 | | 9.4 TS1M0 | |
Microsoft Windows Server 2012 Std | 9.4 | | 9.4 TS1M0 | |
Windows 7 Enterprise x64 | 9.4 | | 9.4 TS1M0 | |
Windows 7 Professional x64 | 9.4 | | 9.4 TS1M0 | |
64-bit Enabled AIX | 9.4 | | 9.4 TS1M0 | |
64-bit Enabled Solaris | 9.4 | | 9.4 TS1M0 | |
HP-UX IPF | 9.4 | | 9.4 TS1M0 | |
Linux for x64 | 9.4 | | 9.4 TS1M0 | |
Solaris for x64 | 9.4 | | 9.4 TS1M0 | |