Sir/Madam,
I am trying to plot a graph of trend for longitudinal data such that, at each visit I have the sample size, standard deviation at the point. The attached file "mycode", contains is my code the runs with error. This link " http://www2.sas.com/proceedings/forum2007/041-2007.pdf" has the plot the way i want it to loo like with some code that I have tried to adapt. My first plots have sample sizes all over the place reather than at specific visit, there are two extra vertical lines. Please, also let me know is there is a simple way to correct my code.
Thank you,
Here is the code that doesnot work well:
%let t = 11; /* sample size */ %let NumSamples = 100; /* number of samples */ data Sim; call streaminit(123); do SampleID = 1 to &NumSamples; /* ID variable for each sample */ do PD=ranbin(0,1,.5); do visit = 1 to &t;
JerKAP = rand("Uniform"); output; end; end; end; run;
proc sort data=sim; by PD visit; run; proc summary data=sim; by PD visit; var JerKAP; output out=mean1 (drop = _:) mean=mean n = n stderr = stderr ; run; *data mean1; *set mean 1; *keep visit PD Jer; *run;
*symbol1 v=dot i=join; symbol1 i = j value = W font = marker c = blue h = 0.5 line = 1 width = 1; symbol2 i = j value = W font = marker c = red h = 0.5 line = 1 width = 1; *axis1 label=(angle=90 "Jer+B1:B46k (AP) (m^2/s^5)"); *title " Jer+B1:B46k (AP) (m^2/s^5) by visit"; proc plot data=mean1; plot mean*visit=PD;; run; quit;
data meanstd; set mean1; if PD= 1 then visit = visit + 0.1; yvalue = mean; output; yvalue = mean + stderr; output; yvalue = mean - stderr; output; run; symbol1 i = hiloj value = W font = marker c = blue h = 0.5 line = 1 width = 1; symbol2 i = hiloj value = W font = marker c = red h =0.5 line = 1 width = 1; proc gplot data = meanstd; plot yvalue*visit =PD / vref = 110 135 lvref =2 href = 2 4 lhref = 1; run; quit;
data numlabel; length function sytle text $ 8; retain function 'label' xsys ysys '2' hsys '3' style 'swissb' size 2 when 'a'; set mean1; y = mean; text = compress(n); if PD = 0 then do; color = 'blue'; x = visitnum + 0.1; end; else if PD = 1 then do; color = 'red'; x = visitnum + 0.2; end; output; run; proc gplot data = meanstd; plot yvalue*visit=PD/vref = 110 135 lvref = 2 href = 2 4 lhref = 1 annotate = numlabel; *format armcd $armf.; run; quit;
data anno1; length function $8 text $8; set mean1; retain xsys ysys '2' hsys '1'; if n > 0 then do; function = "Label"; x = visit; position = "5"; size = 3.5; text = put(n, 2.); style = "swissb"; angle = 0; if PD = 0 then do; y = 94; color = "blue"; output; end; else do; y = 92; color = "red"; output; end; end; run;
data anno2; length function $8 text $8 style $6; retain xsys hsys "1" ysys "2" postion "5" angle 0 size 3.5; PD = 0; x = 1; y = 94; style = "none"; color = "blue"; text = 'dot'; function = 'symbol'; output; PD = 0; x = 4; y = 94; style = "swissb"; color = "blue"; text = "n ="; function = 'label'; output; PD=1; x = 1; y = 92; style = "none"; color = "red"; text = 'dot'; function = 'symbol'; output; PD=1; x = 4; y = 92; style = "swissb"; color = "red"; text = "n ="; function = 'label'; output; run;
data anno3; length function $8 text $8; retain xsys "3" ysys "2" function "label" size 3 color "gray" position "6" x 90; y = 135; text = "ULN"; output; y = 110; text = "LLN"; output; run;
length xsys ysys hsys when position $1 function $8 style color $20 text $50; retain xsys "2" ysys "1" hsys "1"; function = "move"; x = 2; y = 0; output; function = "bar"; color = "grayE8"; style = "solid"; line = 3; when = "b"; x = 4; y = 100; output; function = "move"; x = 3; y = 2; output; function = "label"; text = "Treatment Period"; color = "black"; position = "b"; style = "'Arial'"; size = 5; when = "a"; output; run;
data anno; set anno4 anno1 anno2 anno3 ; run;
symbol1 i = hiloctj c = blue line = 1 width = 5; symbol2 i = hiloctj c = red line = 3 width = 5; symbol3 i = none value = W font = marker c = blue h = 2.5; symbol4 i = none value = W font = marker c = red h = 2.5;
axis1 label = (h = 12 a = 90 "Jer+B1:B46k (AP) (m^2/s^5") minor = none value = (height = 4) major = (width = 3 c = black) width = 3 value = (t=1 " ") order = (0 to 1 by 0.1); axis2 label = (h = 12 "Visit") minor = none value = (height = 4) major = (width = 3 c = black) value = (t=12 " ") width = 3 order = (1 to 6 by 1) offset = (6,0); axis3 label = none order = (0 to 1 by 0.1) value = none major = none minor = none style = 0; legend1 label = none position = (top left inside) offset = (0.5, -0.25) across = 1 value = none
shape = symbol(8,3.5) mode = share; legend2 label = none position = (top left inside) offset = (0.5) across = 1 shape = symbol(8,3.5) mode = share value = (h =4 t= 1 "Control" t = 2 "PD");
proc gplot data = meanstd; plot yvalue*visit=PD /vaxis = axis1 haxis = axis2 legend = legend1 vref = 110 135 lvref = 2 href = 2 4 lhref = 1 annotate = anno; plot2 mean*visit =PD / vaxis = axis3 haxis = axis2 legend = legend2; *format armcd $armf.; run; quit;
... View more