You can use a procedure such as PROC MEANS to calculate the means and standard errors. You can then use these values to calculate the upper and lower error bar limits in a DATA step. Use the HILOCTJ interpolation with PROC GPLOT to generate the graph.
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.
The graphics output on the Results tab was produced using SAS® 9.2. Submitting the sample code with releases of SAS prior to SAS 9.2 might produce different results.
/* Set the graphics environment */
goptions reset=all cback=white border htext=10pt htitle=12pt;
/* 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;
proc sort data=test;
by xvar;
run;
/* Calculate the mean and standard error for each X */
proc means data=test noprint;
by xvar;
var yvar;
output out=meansout mean=mean stderr=stderr;
run;
/* Reshape the data to contain three Y values for */
/* each X for use with the HILOC interpolation. */
data reshape(keep=xvar yvar mean);
set meansout;
yvar=mean;
output;
yvar=mean - stderr;
output;
yvar=mean + stderr;
output;
run;
/* Define the title */
title1 'Plot Means with Standard Error Bars from Calculated Data';
/* Define the axis characteristics */
axis1 offset=(5,5) minor=none;
axis2 label=(angle=90);
/* Define the symbol characteristics */
symbol1 interpol=hiloctj color=blue line=2;
symbol2 interpol=none color=blue value=dot height=1.5;
/* Plot the error bars using the HILOCTJ interpolation */
/* and overlay symbols at the means. */
proc gplot data=reshape;
plot yvar*xvar mean*xvar / overlay haxis=axis1 vaxis=axis2;
run;
quit;
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 ==> GPLOT Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Types ==> Plots ==> Other Plots |
Date Modified: | 2011-02-24 15:26:25 |
Date Created: | 2011-02-24 15:16:58 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | SAS/GRAPH | Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.1 TS1M0 | |
z/OS | 9.1 TS1M0 | |||
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.1 TS1M0 | |||
Microsoft Windows 2000 Advanced Server | 9.1 TS1M0 | |||
Microsoft Windows 2000 Datacenter Server | 9.1 TS1M0 | |||
Microsoft Windows 2000 Server | 9.1 TS1M0 | |||
Microsoft Windows 2000 Professional | 9.1 TS1M0 | |||
Microsoft Windows NT Workstation | 9.1 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter Edition | 9.1 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise Edition | 9.1 TS1M0 | |||
Microsoft Windows Server 2003 Standard Edition | 9.1 TS1M0 | |||
Microsoft Windows XP Professional | 9.1 TS1M0 | |||
64-bit Enabled AIX | 9.1 TS1M0 | |||
64-bit Enabled HP-UX | 9.1 TS1M0 | |||
64-bit Enabled Solaris | 9.1 TS1M0 | |||
HP-UX IPF | 9.1 TS1M0 | |||
Linux | 9.1 TS1M0 | |||
OpenVMS Alpha | 9.1 TS1M0 | |||
Tru64 UNIX | 9.1 TS1M0 |