Sample 43912: Create a Loess fit plot with PROC SGPLOT
This sample illustrates how to use PROC SGPLOT to produce an overlaid fit plot for two groups, Female and Male, following a PROC LOESS fit. We illustrate the technique for a binary response (Y1) and also for a continuous response (Y2).
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 illustrate how to use PROC SGPLOT to produce an overlaid fit plot for two groups, Female and Male, following a PROC LOESS fit. We illustrate the technique for a binary response (Y1) and also for a continuous response (Y2).
Please note that SAS/STAT® and SAS/GRAPH® are required in order to run this sample program.
data a(drop=i seed);
seed = 123456789;
do i = 1 to 50;
x = ranuni(seed);
gender = 'female';
y1 = int(2*ranuni(seed));
y2 = 2*x + abs((2*rannor(seed)));
output;
x = ranuni(seed);
gender = 'male';
y1 = int(2*ranuni(seed));
y2 = 5*x + abs((2*rannor(seed)));
output;
end;
run;
proc sort data=a;
by gender x;
run;
ods listing close;
proc loess data=a;
by gender;
model y1 y2 = x / clm;
score / clm;
ods output ScoreResults=SR;
title1 "LOESS fit for two groups using BY stmt";
title2 "two responses are modeled for illustration:";
title3 "y1 - binary response ";
title4 "y2 - continuous response";
run;
ods html image_dpi=100 file='loessfit.html' path='.' style=listing;
ods graphics / reset noborder width=600px height=400px;
title1 "LOESS Fit Plot";
proc sgplot data=SR;
scatter x=x y=y1 / group=gender;
series x=x y=p_y1 / group=gender;
band x=x lower=lcl_y1 upper=ucl_y1 / group=gender transparency=0.75;
title2 "Binary Response (Y1) - Transparency=0.75";
run;
proc sgplot data=SR;
scatter x=x y=y2 / group=gender;
series x=x y=p_y2 / group=gender;
band x=x lower=lcl_y2 upper=ucl_y2 / group=gender transparency=0.5;
title2 "Continuous Response (Y2) - Transparency=0.5";
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 illustrates how to create a Loess fit plot with the SGPLOT procedure.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> SGPLOT
|
Date Modified: | 2011-10-17 14:15:53 |
Date Created: | 2011-08-04 12:03:02 |
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 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 | |
Windows Vista for x64 | 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 | |