@MJ1985 wrote:
What I have now is this, a fixed dataset final which is my design matrix and a file combinedrandom which has all the random coefficients. I can combine the two and use the arrays, do the multiplcations by which i get response variables, and produce a mixed model. however, i want to do this a 1000 times and i cannot figure out how to implement that outer loop when i have so much datasteps reading and setting files. Much help appreciated here.
%let nBlock=8;
%let nDep=5;
%let nPen=20;
%let N=1;
%let PigVariance=0.006;
%let PenVariance=0.006;
%let BlockVariance=0.003;
%let DepVariance=0.0005;
data combinedrandom(drop=i j k l);
array b{&nBlock} b1-b&nBlock;
array d{&nDep} d1-d&nDep;
array p{&nPen} p1-p&nPen;
do j=1 to &nBlock; /* j=1 to 8 */
b{j} = rand("Normal", 0, &BlockVariance);
end;
do k=1 to &nDep;
d{k} = rand("Normal", 0, &DepVariance);
end;
do l=1 to &nPen; /* j=1 to 8 */
p{l} = rand("Normal", 0, &PenVariance);
end;
do i=1 to &N;
output;
end;
run;
data want;
set final;
do z=1 to nobs;
set combinedrandom point=z nobs=nobs;
array b{8} b1-b8;
array d{5} d1-d5;
array p{20} p1-p20;
array t[5] _temporary_ (0.670 0.660 0.650 0.640 0.630);
array s[2] _temporary_ (0 -0.10);
y=t[trt]+s[sex]+b[block]+d[dep]+p[pen]+rand("Normal", 0, sqrt(&PigVariance));
output;
end;
run;
proc mixed data=want covtest plots=all;
class dep block pen sex trt;
model y=trt sex dep / s cl ddfm=kenwardroger2;
random block pen / s cl;
lsmeans trt / pdiff=all adjdfe=row adjust=simulate;
run;
What is the outer loop? Are you doing repitiions?
If so you could try adding a REP variable and using that.
data combinedrandom(drop=i j k l);
do REPNO=1 to 1000;
....
end;
run;
....
proc sort data=want ;
by REPNO ;
run;
proc mixed data=want covtest plots=all;
by REPNO;
...
run;
You probable do NOT want to print all 1000 repetitions so add some OUTPUT options to your PROC MIXED and store the results you want into datasets and review those.
... View more