Dear all; I'm looking for some help in translating the following SAS code to R. The code represents a factorial design plus 1 control plot (2 x 2 + 1). The data is the following BLOCK FA FB FC Y 1 0 0 0 15.33 1 1 0 0 14.40 1 1 1 0 15.49 1 1 0 1 16.87 1 1 1 1 18.84 2 0 0 0 15.97 2 1 0 0 16.18 2 1 1 0 14.52 2 1 0 1 18.04 2 1 1 1 19.81 3 0 0 0 15.60 3 1 0 0 14.79 3 1 1 0 14.30 3 1 0 1 17.18 3 1 1 1 18.37 4 0 0 0 15.22 4 1 0 0 16.24 4 1 1 0 15.97 4 1 0 1 16.51 4 1 1 1 19.05 The SAS code is: proc glm data=test; class BLOCK FA FB FC; model Y = BLOCK FA FB(FA) FC(FA) FB*FC(FA)/alpha=0.05; random BLOCK/test; lsmeans FB*FC(FA)/pdiff stderr; quit; run; I've tried: library(nlme) options(contrasts=c("contr.SAS","contr.SAS")) data.gr<-groupedData(Y~1|BLocK,data=data) data.gr$BLocK<-as.factor(data.gr$BLocK);data.gr$FA<-as.factor(data.gr$FA) data.gr$FB<-as.factor(data.gr$FB);data.gr$FC<-as.factor(data.gr$FC) mod1<-lme(Y~FA+(FB*FC)/FA,random=~1|BLOCK,data=data.gr) but I can't get the model works and I can't figure out how can I do it. I'll appreciate any ideas Best regards P. Porras