/* RepeatedMantids.sas */ title 'Mantids Data: Thanks to Stephanie Hill'; proc format; value sexfmt 0 = 'Male' 1 = 'Female'; value dfmt 1 = '1=8cm' 2 = '2=13cm' 3 = '3=18cm'; value birdfmt 1='Vinny' 2='Chickpea' 3='Emily' 4='Bramble'; data bugs; /* Univariate Data Read. Skip the first line. */ infile '/folders/myfolders/mantids.data.txt' firstobs=2; input id Sex Order Predator Distance Calls; format sex sexfmt. distance dfmt. Predator birdfmt. ; proc freq; tables sex*predator*distance / norow nocol nopercent missing; proc mixed; title2 'Predator is a fixed effect'; class Sex Predator Distance; model calls = Sex|Predator|Distance; repeated / type=un subject=id; lsmeans sex distance Predator*Distance; proc mixed cl; /* Confidence Limits for random effects */ title2 'Predator is a random effect'; class Sex Predator Distance; model calls = Sex|Distance; random Predator Predator*Sex Predator*Distance Predator*Sex*Distance; repeated / type=cs subject=id; proc mixed cl; title2 'No interactions of fixed effects factors with Predator'; class Sex Predator Distance; model calls = Sex|Distance; random Predator; repeated / type=cs subject=id; lsmeans sex; lsmeans distance / pdiff tdiff adjust = bon;