Sample 31510: Stacked band plot with overlay lines
This sample program uses the SGPLOT procedure to create a stacked band plot with overlay lines.
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 program uses the SGPLOT procedure to create a stacked band plot with overlay lines.
data bmi;
infile datalines;
input category $ 1-11 upper_bmi lower_bmi weight_bmi;
lower_hgt=(703*weight_bmi/lower_bmi)**.5;
upper_hgt=(703*weight_bmi/upper_bmi)**.5;
nn=_n_;
datalines;
Underweight 1 18.5 25.0 4
Underweight 1 18.5 100.0 4
Underweight 1 18.5 175.0 4
Underweight 1 18.5 250.0 4
Underweight 1 18.5 325.0 4
Normal 18.5 25.0 25.0 5
Normal 18.5 25.0 100.0 5
Normal 18.5 25.0 175.0 5
Normal 18.5 25.0 250.0 5
Normal 18.5 25.0 325.0 5
Overweight 25.0 30.0 25.0 6
Overweight 25.0 30.0 100.0 6
Overweight 25.0 30.0 175.0 6
Overweight 25.0 30.0 250.0 6
Overweight 25.0 30.0 325.0 6
Obese 30.0 150.0 25.0 7
Obese 30.0 150.0 100.0 7
Obese 30.0 150.0 175.0 7
Obese 30.0 150.0 250.0 7
Obese 30.0 150.0 325.0 7
;
run;
data records;
infile datalines;
nn=_n_;
input wgt hgt year name $ ;
datalines;
45 52 1975 Bob
80 56 1980 Bob
125 66 1986 Bob
175 67 1990 Bob
200 68 1995 Bob
215 69 2000 Bob
250 69 2005 Bob
80 43 1975 Fred
85 58 1980 Fred
135 70 1986 Fred
180 70 1990 Fred
195 70 2005 Fred
50 42 1975 Jack
135 54 1980 Jack
140 64 1985 Jack
160 73 1990 Jack
170 76 2000 Jack
180 76 2005 Jack
;
run;
proc sort data=bmi;
by nn;
run;
proc sort data=records;
by nn;
run;
data merged;
merge bmi records;
by nn;
if name='' then name='Jack';
run;
proc template;
define style styles.bmi;
parent=styles.analysis;
style graphcolors from graphcolors /
'gcdata1'=CX31035E
'gcdata2'=CXB2182B
'gcdata3'=CX01665E
'gdata1'=CXFFFFFF
'gdata3'=CXFDC861
'gdata4'=CXDC531F
'gdata2'=CX679920;
end;
run;
ods listing close;
ods html file='bmi.html' path='.' style=styles.bmi;
ods graphics / reset width=600px height=400px imagename="BMI" imagefmt=gif;
title 'Three Patient Growth Charts vs BMI';
proc sgplot data=merged;
band x=weight_bmi upper=upper_hgt lower=lower_hgt /
transparency=.5 group=category name="bmi";
xaxis min=30 max=300 label='Weight (lbs)' grid;
yaxis min=40 max=80 label='Height (in)' grid;
keylegend "bmi" / position=bottom location=outside across=4 title='BMI: ';
series x=wgt y=hgt / datalabel=year lineattrs=(pattern=solid thickness=2px)
markerattrs=(symbol=circlefilled ) markers group=name name="pts";
keylegend "pts" / position=topleft location=inside across=1 title='Patient:';
inset "BMI=703 x Weight / Height (*ESC*){sup '2'}" " " /
position=bottomright textattrs=graphfootnotetext;
run;
ods html close;
ods listing;
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 program uses the SGPLOT procedure to create a stacked
band plot with overlay lines.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> SGPLOT Query and Reporting ==> Creating Reports ==> Graphical ==> Health and Life Sciences Industry
|
Date Modified: | 2009-03-20 14:35:02 |
Date Created: | 2008-03-18 10:38:47 |
Operating System and Release Information
SAS System | SAS/GRAPH | z/OS | 9.2 TS1M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | |
Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | |
Microsoft® Windows® for x64 | 9.2 TS1M0 | |
Microsoft Windows 2000 Advanced Server | 9.2 TS1M0 | |
Microsoft Windows 2000 Datacenter Server | 9.2 TS1M0 | |
Microsoft Windows 2000 Server | 9.2 TS1M0 | |
Microsoft Windows 2000 Professional | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | |
Microsoft Windows XP Professional | 9.2 TS1M0 | |
Windows Vista | 9.2 TS1M0 | |
64-bit Enabled AIX | 9.2 TS1M0 | |
64-bit Enabled HP-UX | 9.2 TS1M0 | |
64-bit Enabled Solaris | 9.2 TS1M0 | |
HP-UX IPF | 9.2 TS1M0 | |
Linux | 9.2 TS1M0 | |
Linux for x64 | 9.2 TS1M0 | |
OpenVMS on HP Integrity | 9.2 TS1M0 | |
Solaris for x64 | 9.2 TS1M0 | |