Created
September 29, 2021 18:15
-
-
Save MJacobs1985/8d3335d7618475ff807527095db76234 to your computer and use it in GitHub Desktop.
Simulations in SAS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%let ErrorVariance=1000; | |
%let BlockVariance=3000; | |
%let block=18; | |
%let nsim=1; | |
data factor; | |
length Treatment $30; | |
call streaminit(123); | |
do isim = 1 to ≁ | |
do block=1 to █ | |
rndBlock=rand("Normal",0,sqrt(&BlockVariance)); /* create block specific deviates */ | |
do Protein=0 to 1 by 1; | |
do Moisture=0 to 1 by 1; | |
adg0042=550*Protein + 325*Moisture + -400*Protein*Moisture + rndBlock + rand("Normal",0,sqrt(&ErrorVariance)); | |
if Moisture=0 & Protein=0 then Treatment="Low Moisture / Low Protein"; | |
if Moisture=0 & Protein=1 then Treatment="Low Moisture / High Protein"; | |
if Moisture=1 & Protein=0 then Treatment="High Moisture / Low Protein"; | |
if Moisture=1 & Protein=1 then Treatment="High Moisture / High Protein"; | |
output; | |
end; | |
end; | |
end; | |
end; | |
ods graphics / imagefmt=svg; | |
proc sgplot data=factor; | |
vbox adg0042 / category=protein group=moisture; | |
title "Boxplot showing levels of Moisture & Protein "; | |
run; | |
proc sgplot data=factor; | |
vbox adg0042 / group=Treatment; | |
title "Boxplot showing four Treatments "; | |
run; | |
proc mixed data=factor; | |
class protein moisture block; | |
model adg0042=protein|moisture / s cl ddfm=kenwardroger; | |
store mixmodel; | |
run; | |
proc plm restore=mixmodel; | |
effectplot interaction(x=moisture sliceby=protein) / connect clm ilink; | |
effectplot interaction (x=protein plotby=moisture) / connect ilink clm; | |
slice protein*moisture / sliceby=moisture pdiff=all means lines cl ilink adjust=tukey plots=diffogram; | |
lsmeans protein*moisture / lines ilink; | |
run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment