Date: Tue, 6 Mar 2007 12:44:20 -0800
Reply-To: monal kohli <k_monal_99@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: monal kohli <k_monal_99@YAHOO.COM>
Subject: Fw: Creating Errorbars in Plots from Summary Data
Content-Type: text/plain; charset=iso-8859-1
Dale,
Jeff gave me a piece of code which gave me an idea how to get the exact output I needed. And it did work.
Below is the code for everyone .
Thanks again everyone.
Much appreciated.
Mona
----- Forwarded Message ----
From: Jeff Cartier <Jeff.Cartier@sas.com>
To: k_monal_99@YAHOO.COM
Sent: Tuesday, March 6, 2007 1:37:36 PM
Subject: Creating Errorbars in Plots from Summary Data
Monal,
As others have pointed out, your starting point is summarized data, not the original study data.
If you have your original study data, GPLOT with the INTERPOLATION you selected will work.
If you pass in summarized data it won't work because there are not enough observations (1) per treatment group and the computation is not done.
If you don't have access to the original data, you can still create the plot you want, but it will have to done with annotate. Here is an example that should be easy to adjust to your situation.
Jeff Cartier
SAS Instititue
data study; /* original detail data */
set sashelp.class;
age=age-1;
n=1;
do Year=2000 to 2005;
age=age+1;
factor=(n+.05);
weight=round(factor*weight + 10*rannor(1));
output;
end;
run;
proc summary data=study; /* summary data */
class year;
var weight;
output out=stats mean=Mean stderr=Std_Error;
run;
data errorbars; /* annotation data set */
length X Y SIZE LINE 8 FUNCTION COLOR $8 XSYS YSYS POSITION WHEN $1 TEXT $20;
set stats;
if _type_ = 0 then do;
/* mean of all years */
XSYS="1"; YSYS="2"; WHEN="A";
FUNCTION="MOVE"; X=0; Y=Mean; output;
FUNCTION="DRAW"; X=100; Y=Mean; COLOR="gray"; LINE=2; SIZE=1; output;
FUNCTION="LABEL"; POSITION="C"; TEXT=" Overall"; output;
FUNCTION="LABEL"; POSITION="F"; TEXT=put(Mean,6.1); output;
end;
else do;
/* mean per year */
XSYS="2"; YSYS="2"; WHEN="A";
FUNCTION="MOVE"; X=Year; Y=Mean+Std_Error; output;
FUNCTION="DRAW"; X=Year; Y=Mean-Std_Error; COLOR="blue"; SIZE=2; output;
end;
run;
goptions reset=all ;
symbol i=join value=circle color=black;
axis1 minor=none label=(angle=90 'Mean Weight in Pounds') order=80 to 140 by 20;
title1 "Mean Weight per Year";
title2 color=blue "Errorbars show +/- 1 SE";
proc gplot data=stats(where=(_TYPE_=1)) anno=errorbars;
plot Mean*Year / hminor=0 vaxis=axis1;
run; quit;
proc gchart data=stats(where=(_TYPE_=1)) anno=errorbars;
vbar Year / discrete sumvar=mean raxis=axis1;
run; quit;
____________________________________________________________________________________
Looking for earth-friendly autos?
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/