LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2007, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 7 Mar 2007 08:40:02 -0600
Reply-To:   Yu Zhang <zhangyu05@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Yu Zhang <zhangyu05@GMAIL.COM>
Subject:   Re: Fw: Creating Errorbars in Plots from Summary Data
Comments:   To: monal kohli <k_monal_99@yahoo.com>
In-Reply-To:   <161865.67171.qm@web54201.mail.yahoo.com>
Content-Type:   text/plain; charset=ISO-8859-1; format=flowed

Monal,

Sorry for the late reply. I saw Jeff gave you a every nice solution using annotation to draw error bar. In order to use the i=std1tj to draw the error bar, you have to create three variables (High, LOW and CLOSE) which are required by this option. it doesn't matter whether or not you have the access to the original dataset. I borrowed the dataset from Jeff's post.

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;

/*creating the LOW, High and close variables*/ data stats; set stats (where=(_type_=1)); type='LOW ';var=mean-std_error;output; type='HIGH ';var=mean+std_error;output; type='CLOSE';var=mean;output;

run;

symbol1 v=none h=0.3 i=stdt1j; proc gplot data=stats; plot var*year; run;

HTH Yu

On 3/6/07, monal kohli <k_monal_99@yahoo.com> wrote: > > 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/ >


Back to: Top of message | Previous page | Main SAS-L page