You can split your data set on the fly. Use a by statement to split treatments and conduct parallel analyses.
What happens when a violation of test assumptions derails your analysis plan? You can quickly split treatments into two analysis using the “by” statement in mixed model procedures.
We uploaded the dataset from a study on heath plants tested the effect of plant source, drought and nitrogen. Researchers performed the experiment twice in a greenhouse over two years. A previous data review showed different results by year.
Suppose you want to quickly evaluate each experimental repeat (year) independently and simultaneously. We do this by inserting a “by” statement into the statistical test procedure.
*** Start by sorting the data;
proc sort data=Heath.data;
by Year Heathland Nitrogen Drought Replicate;
*** this “by” modifies the proc sort statement. Below, we will use by to modify the ANOVA procedure;
run;
ods html close;
run;
ods graphics on;
proc mixed data=Heath.data Plots(only)=(studentpanel(conditional) Boxplot(conditional));
by 'Year'n;
***The sort by year creates one analysis output for each year.;
class Year Heathland Nitrogen Drought Replicate;
model 'dry weight above (g)'n= Drought|Nitrogen|Heathland;
random 'Year'n;
RUN;
2010 residual plots
2011 residual plots
And voila, your analysis is split by year! Notice the residual variance no longer violates our normality assumption.
If we were interested in only one year’s data, we could use the “Like” conditional statement.
While most of us find frustration in model assumption violations, segmenting observations does not have to be. The 'by' statement is one way to split treatments and execute parallel tests when the full factor model falls short.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.