Hello! I was presented with this model statement today, and am confused why you would nest an individual within a treatment?
example
data hotties;
input ID trt day time rtemp;
datalines;
1 1 3 1 103.6
1 1 3 2 103.6
1 1 4 1 104.2
1 1 4 2 104.6
2 2 3 1 102.1
2 2 3 2 102.6
2 2 4 1 102.2
2 2 4 2 103.6
3 1 3 1 103.1
3 1 3 2 103.5
3 1 4 1 102.9
3 1 4 2 103.2
etc.
class ID trt day time;
model rtemp = trt|day|time/ ddfm=satterw;
repeat day/ sub = ID(trt); <<<<<<<< the sub = ID(trt), this is the part I do not understand what it does or why you would use it in this senario. Any thoughts? The SAS description of sub is to create a block, which is great. But my interpretation of this is that individual is then blocked by treatment, which does not make a whole lot of sense to me. Why would you block by treatment? Or am I interpretting this incorrectly?
if your ID is unique ,then you can use
repeat day/ sub = ID
But if not ,then you have to use
repeat day/ sub = ID(trt)
or
repeat day/ sub = ID*trt
to make subject id(strata) is unique.
E.X.
id trt
1 1
2 1
1 2
2 2
for this kind of data you have to use sub=id(trt) .
The syntax
repeated day / subject=id(trt);
corresponds to an experimental design in which each subject (id) is randomly assigned to one level of trt, and multiple observations are made on each id at each level of day. As such, ids are nested within levels of trt: each id belongs to only one level of trt.
id(trt) identifies a random effects factor that has one level for each unique combination of id and trt. It does not mean that trt is random; it's just a syntax shortcut.
Alternatively, you could assign each subject a unique id value and use
repeated day / subject=unique_id;
which is the point that @Ksharp is making.
Even with unique values for subjects, I still use the nested syntax because it does a better job of giving me the denominator df that I think are appropriate.
I note that you have time in the MODEL statement. I bet this is a repeated measures factor as well, probably multiple times within each day. If so, your model is wrong, along with your understanding of the MIXED syntax. But that's another topic.
I highly recommend
It will tell you most of what you need to know.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.