Date: Wed, 18 Mar 2009 14:48:53 -0400
Reply-To: msz03@albany.edu
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mike Zdeb <msz03@ALBANY.EDU>
Subject: Re: Graph of mean and CIs for two treatments over time
Content-Type: text/plain;charset=iso-8859-1
hi ... here's a suggestion
I removed your EMF and RTF stuff while messing around with this (you can put it back) and made a few other tweaks (you can fix)
I think this does what you want using a HILOJT symbol and no annotate
I moved the x-values left/right based by a fixed % not a fixed absolute value
give it a try and see if it's what you wanted
* your data;
data test;
INPUT trt $ timepnt lci mean uci ;
DATALINES;
0 1 0.180657886 0.186451748 0.19224561
1 1 0.176110241 0.195548978 0.214987714
0 2 0.176826101 0.18369983 0.190573559
1 2 0.166709913 0.183846446 0.20098298
0 3 0.200911478 0.208383265 0.215855051
1 3 0.21118932 0.233555874 0.255922428
0 4 0.236822881 0.243940764 0.251058646
1 4 0.221677871 0.246383049 0.271088226
;
run;
*
move the time points left and right based on value of TRT
tweak data so you can use the HILOJT symbol
create three Y-values for each X-value
;
data test;
set test;
x = timepnt - (trt eq '0')*.025 + (trt eq '1')*.025;
y = mean; output;
y = lci; output;
y = uci; output;
run;
goptions reset=all ftext='arial/bo' htext=2 gunit=pct;
*
use ORDER to add some room on the left and right
since X-values have been moved left and right
otherwise, default is to go from 0 to 5
suppress the values except for 1 2 3 4
;
axis1 label=('Timepoint') minor=none major=none order=0.75 to 4.25 by 0.25
value=('' '1' '' '' '' '2' '' '' '' '3' '' '' '' '4' '');
axis2 label=(a=90 "Label");
*
Symbol statements for line plot (patients)
use HILOJT to J(oin) points and use T(op and bottom) bars
;
symbol1 color=black interpol=hilojt width=3;
symbol2 color=red interpol=hilojt width=3;
legend1 label=none position=(top inside left)
value=(justify=left) across=2 cborder=black shape=symbol(3,0.2);
title1 "Mean Values by Timepoint" ls=2;
title2 a=90 ls=2;
title3 a=270 ls=2;
footnote1 ls=1;
proc gplot data=test;
plot y*x=trt /
haxis = axis1 vaxis = axis2 legend=legend1 noframe;
run;
quit;
--
Mike Zdeb
U@Albany School of Public Health
One University Place
Rensselaer, New York 12144-3456
P/518-402-6479 F/630-604-1475
> Dear SAS-L
>
> I'm trying to generate a graph of mean value (y-axis) against timepoint
> (x-axis). There are two treatment groups that need to appear on the
> same plot in different colours. I want to join the means for each group
> over time. I also want to add the 95% CIs joined by a vertical line and
> with little horizontal lines on the end (I'm sorry, I don't know how
> better to describe them, but I believe this is a common graph). The
> confidence intervals is the bit I'm having trouble with. A old post in
> the archives suggests using annotate, but I can't get it to work. I
> also need the two treatments offset from each other slightly, or they
> will be on top of each other as the values are similar.
>
> I have already generated the mean and CI values.
>
> Below is my code as it stands, is anyone able to help me out?
>
> Thank-you very much for your time
>
> Anna
>
> goptions
> reset=all
> device=emf
> htext=11pt
> htitle=14pt
> hsize = 15 cm
> vsize = 15 cm
> ftext = simplex
> ;
>
> options leftmargin=1in rightmargin=1in topmargin=1in bottommargin=1in;
>
>
> data test;
> INPUT trt $ timepnt $ lci mean uci ;
> DATALINES;
> 0 1 0.180657886 0.186451748 0.19224561
> 1 1 0.176110241 0.195548978 0.214987714
> 0 2 0.176826101 0.18369983 0.190573559
> 1 2 0.166709913 0.183846446 0.20098298
> 0 3 0.200911478 0.208383265 0.215855051
> 1 3 0.21118932 0.233555874 0.255922428
> 0 4 0.236822881 0.243940764 0.251058646
> 1 4 0.221677871 0.246383049 0.271088226
> PROC PRINT; RUN;
>
> %annomac;
> data anno;
> xsys='2'; ysys='2';
> set test (keep = uci lci trt timepnt);
> if trt='A' then do; %line(timepnt-0.05,lci,timepnt-0.05,uci,black,1,5);
> end; /* draws confidence intervals */
> if trt='B' then do; %line(timepnt+0.05,lci,timepnt+0.05,uci,red,1,5);
> end; /* draws confidence intervals */
> run;
>
> axis1 label = ('Timepoint')
> minor=none;
> axis2 label = (a=90 "Label")
> ;
>
> * Symbol statements for line plot (patients) *;
> symbol1 color=black
> interpol=hilot
> value=dot
> line=1
> width=5;
>
> symbol2 color=red
> interpol=hilot
> value=dot
> line=1
> width=5;
>
> legend1 label=none
> value=(justify=left)
> across=1 down=2
> cborder=black
> shape=symbol(3,0.2)
> ;
> ods listing close;
> ods rtf file = "C:\test.rtf" bodytitle sasdate ;
>
> title "Mean values by timepoint";
> options nonumber nodate orientation=portrait;
>
>
> proc gplot data = test annotate=anno;
> plot mean*timepnt=trt / haxis = axis1 vaxis = axis2 legend=legend1
> noframe;
> run;
> quit;
>
> ods rtf close;
> ods listing;
>
>