Sample 42542: Plot means with standard error bars from calculated data with PROC SGPLOT
This sample illustrates how to plot means with standard error bars from calculated data with the SGPLOT procedure.
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 plot means with standard error bars from calculated data with the SGPLOT procedure.
/* Create sample data */
data test(drop=i);
do i=1 to 10;
do xvar=1 to 5;
yvar=ranuni(0)*100;
output;
end;
end;
run;
/* Calculate the means and the standard errors. */
proc sort data=test;
by xvar;
run;
proc means data=test noprint;
by xvar;
var yvar;
output out=meansout mean=mean stderr=stderr;
run;
/* Calculate the upper and lower error bar values. */
data reshape(drop=stderr);
set meansout;
lower=mean - stderr;
upper=mean + stderr;
run;
ods listing close;
ods html file='scatterplot.html' path='.' style=styles.statistical;
ods graphics / reset width=600px height=400px imagefmt=gif;
/* The SCATTER statement generates the scatter plot with error bars. */
/* The SERIES statement draws the line to connect the means. */
proc sgplot data=reshape noautolegend;
scatter x=xvar y=mean / yerrorlower=lower
yerrorupper=upper
markerattrs=(color=blue symbol=CircleFilled);
series x=xvar y=mean / lineattrs=(color=blue pattern=2);
title1 'Plot Means with Standard Error Bars from Calculated Data';
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 plot means with standard error bars from calculated data with the SGPLOT procedure.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> SGPLOT
|
Date Modified: | 2011-02-28 13:03:24 |
Date Created: | 2011-02-28 12:48:06 |
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 | |