Date: Sun, 14 Jul 1996 09:05:29 +0300
Reply-To: Dvora Zomer <epid04@POST.TAU.AC.IL>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Dvora Zomer <epid04@POST.TAU.AC.IL>
Subject: Re: plotting problem (predicted values and confidence intervals)
In-Reply-To: <Pine.3.89.9607021131.A8667-0100000@unixs1.cis.pitt.edu>
On Tue, 2 Jul 1996, Laura C Schmidt wrote:
> Hi, SAS-Lers,
>
> I have a rather challenging problem (I think). I have 3 cohorts of
> subjects: one group is 6-11 years old and their id numbers are 10000s,
> another is 9-14 years old with id numbers in the 40000s, and
> another is 12-18 years old with id numbers in the 70000s. Some subjects
> are assessed two times at the
> same age. Most do not have data over the entire age range within their
> cohort.
> I am trying to plot the predicted values for each group over
> age (not time). (I'd love to get lower and upper confidence intervals
> plotted as well, but I should probably keep it simple first). I
> have used proc mixed to print out predicted values for my data. What
> I can't seem to do, is reduce this file so that I can plot the predicted
> values of each group over age. The data looks like this:
>
> id cohort time age predicted
> 10004 1 1 6 40.34 (not all are 6 at time 1--
> 10004 1 2 7 40.03 some are older)
> 10004 1 3 7 40.03
> 10004 1 4 8 39.73
> 10004 1 5 8 39.73
> 10004 1 6 9 39.42
> 10007 1 1 7 40.03
> etc. (n=500 in this 10000s group, each with multiple records)
>
> 40001 2 1 10 41.71
> 40001 2 2 10 41.71
> 40001 2 4 12 42.21 (missed time 3 assessment)
> 40001 2 5 13 42.20
> 40004
> etc. (n=500 in this 40000s group, each with multiple records)
>
> 70003 3 1 12 42.57
> 70003 3 2 12 42.57
> ...
> 70003 3 9 18 45.40
> 70010
> etc. (n=500 in this 7000s group, each with multiple records).
>
> In the Introduction to the Mixed Procedure Course Notes book from SAS,
> on page 200, there are comands like this, but I need to elaborate on them
> in order to collapse the multiple observations at each age, I think:
>
> proc sort data=pred; /* pred has predicted values*/
> by cohort id;
> run;
>
> data predmean (drop=firstsub);
> retain firstsub;
> set pred;
> by cohort id;
> if first.cohort then firstsub=1; /*this is especially difficult for me*/
> if firstsub=1 then do; /*I think some code with age is needed here*/
> output;
> if last.subj then firstsub=0;
> end;
> run;
>
> proc gplot data=predmean;
> plot pred*age=cohort /...etc.
>
>
> I hope this is sufficient information, and thanks in advance, Laura
>
> ************************
> Laura C. Schmidt
> University of Pittsburgh
> lschmidt+@pitt.edu
>
Dear Laura:
If I understood well, in each cohort predicted values depend only of age.
If so, the following text will help you.
============================================================
data pred ;
input id cohort time a pmean plow pup ;
cards ;
10004 1 1 6 40.34 35.34 45.34
10004 1 2 7 40.03 35.03 45.03
10004 1 3 7 40.03 35.03 45.03
10004 1 4 8 39.73 33.73 43.73
10004 1 5 8 39.73 33.73 45.73
10004 1 6 9 39.42 35.42 43.42
10004 1 7 10 38.04 35.04 41.04
10004 1 8 11 39.73 34.73 43.73
10005 1 1 7 40.03 35.03 45.03
10005 1 2 7 40.03 35.03 45.03
10005 1 4 9 39.42 35.42 43.42
10005 1 6 10 38.04 35.04 41.04
10006 1 1 6 40.34 35.34 45.34
10006 1 2 7 40.03 35.03 45.03
10006 1 4 9 39.42 35.42 43.42
10006 1 7 11 39.73 34.73 43.73
40001 2 1 9 40.01 36.01 44.01
40001 2 2 10 40.93 35.93 45.93
40001 2 3 11 41.53 36.53 46.53
40001 2 4 12 42.22 38.22 46.22
40001 2 5 13 41.73 35.73 46.73
40001 2 6 14 38.02 32.02 44.02
40002 2 1 10 40.93 35.93 45.93
40002 2 2 11 41.53 36.53 46.53
40002 2 3 11 41.53 36.53 46.53
40002 2 4 12 42.22 38.22 46.22
40002 2 6 14 38.02 32.02 44.02
70007 3 1 12 40.34 35.34 45.34
70007 3 2 13 40.03 35.03 45.03
70007 3 3 13 40.03 35.03 45.03
70007 3 4 14 39.73 33.73 43.73
70007 3 5 14 39.73 33.73 45.73
70007 3 6 15 39.42 35.42 43.42
70007 3 7 16 38.04 35.04 41.04
70007 3 8 17 39.73 34.73 43.73
70009 3 2 13 40.03 35.03 45.03
70009 3 5 14 39.73 33.73 45.73
70009 3 6 15 39.42 35.42 43.42
70009 3 8 17 39.73 34.73 43.73
70009 3 9 18 39.73 34.73 43.73
;
proc sort ;
by cohort a ;
data b;
keep age z cohort ;
set pred ;
by cohort a ;
if first.a then do ;
if (co=1) then age=a-.1 ;
if (co=3) then age=a+.1 ;
if (co=2) then age=a ;
z=plow ;
output ;
z=pmean ;
output ;
z=pup ;
output ;
end ;
goptions device=egac ;
symbol1 I=HILOt ci=yellow ;
symbol2 I=HILOt ci=red ;
symbol3 I=HILOt ci=blue ;
proc gplot ;
plot z*age=cohort ;
run;
=================================
Best regards.
Ilya Novikov, Ph.D.
Senior Statistician
Chaim Sheba Medical Center
Israel
|