Ridgetown Grad Student Session: April 16, 2026

Better late than never right? Rather than emailing the materials – I will post here online – you can bookmark and retrieve when you need it.

Here are the 4 files

Power point presentation

SAS code for the Mixed Model analysis – note that it has a .txt ending – you can open this in any text editor program and you can open it in SAS. I have added comments and notes in the SAS code – hopefully they help or will remind you of things we discussed.

Data trial;
  infile "/home/edwardsm0/sasuser.v94/Agricola_Consulting/Workshop/RGN/Model_data_20260415.csv" firstobs=2 dlm=",";
  input SampleID$ Time Block Plot Ntrmt Crop$ Height;
Run;

/*  Linear Mixed Model ANOVA  */

Proc glimmix data=trial;* nobound;  /* nobound option added to allow SAS to provide us with random effect estimates that are < 0. */
  class block crop Ntrmt;
  model height = crop|Ntrmt;
  random block block*crop block*ntrmt block*crop*ntrmt;
  lsmeans crop|ntrmt/adjust=tukey lines;
  output out=second predicted=pred residual=resid residual(noblup)=mresid student=studentresid student(noblup)=smresid;
run;

/*  Linearity of fixed effects - scatter and boxplot */ 
Proc sgplot data=second; 
  vbox smresid / group=block datalabel;
Run;

Proc sgplot data=second; 
  vbox smresid / group=crop datalabel;
Run;

Proc sgplot data=second; 
  vbox smresid / group=ntrmt datalabel;
Run;

/* Homogeneity of effects */ 
Proc sgscatter data=second;
  plot studentresid*(pred block crop ntrmt); 
Run; 

/* Q-Q plot and Shapiro-Wilk for normal distribution */ 
proc univariate data=second normal plot;
  var studentresid; 
Run;

SAS code for the Repeated Measures Mixed Model analysis – note that it has a .txt ending – you can open this in any text editor program and you can open it in SAS. I have added comments and notes in the SAS code – hopefully they help or will remind you of things we discussed.

Data trial;
  infile "/home/edwardsm0/sasuser.v94/Agricola_Consulting/Workshop/RGN/Model_data_20260415.csv" firstobs=2 dlm=",";
  input SampleID$ Time Block Plot Ntrmt Crop$ Height;
Run;


/*  Repeated Linear Mixed Model ANOVA  */

Proc glimmix data=trial;* nobound; /* nobound option added to allow SAS to provide us with random effect estimates that are < 0. */
  class block crop Ntrmt time;
  model height = crop|Ntrmt|time;
  random block block*crop block*ntrmt block*crop*ntrmt;
/* this is the REPEATED statement - subject identifies the experimental unit */
/* random and residual let SAS know that this is a repeated ANOVA. */
/* the variable listed after random is the column in the dataset that identifies the repeat */
/* type = cs - identifies the relationship between the repeats - CS - compound symmetry assumes 
	equal distances between the repeats - and no relationships between the repeats */  
  random time / subject=block*plot*ntrmt type=cs residual; 
  lsmeans crop|ntrmt/adjust=tukey lines;
  output out=second predicted=pred residual=resid residual(noblup)=mresid student=studentresid student(noblup)=smresid;
run;

/*  Linearity of fixed effects - scatter and boxplot */ 
Proc sgplot data=second; 
  vbox smresid / group=block datalabel;
Run;

Proc sgplot data=second; 
  vbox smresid / group=crop datalabel;
Run;

Proc sgplot data=second; 
  vbox smresid / group=ntrmt datalabel;
Run;

/* Homogeneity of effects */ 
Proc sgscatter data=second;
  plot studentresid*(pred block crop ntrmt); 
Run; 

/* Q-Q plot and Shapiro-Wilk for normal distribution */ 
proc univariate data=second normal plot;
  var studentresid; 
Run;

Excel file that has the DUMMY data created for this workshop

Upcoming materials

I am still working on the R code to match the SAS code. I’m struggling with replicating the same results – as soon as I have it – I will email and post code in a new blogpost.

Questions

If you have ANY questions – please let me know. Please email me at michelle@agricolaconsulting.ca.

Thanks!!

Leave a comment

Michelle Edwards

Michelle Edwards is a self-proclaimed data geek who teaches statistics and experimental design to anyone willing to listen. She has been told on many occasions that she can translate “statistics-ese” to english, making statistics FUN!