OPTIONS ls=100 ps=60 nodate nonumber; proc iml; /********* The Parameters **************/ NS=20; /* No. of subjects */ /* The population correlation matrix is entered as YY YX, XY XX */ PopCor={1 .5 .5 .7 .7 .1, .5 1 .5 .7 .7 .1, .5 .5 1 .7 .7 .1, .7 .7 .7 1 .2 .2, .7 .7 .7 .2 1 .2, .1 .1 .1 .2 .2 1}; %Let NY=3; /* No. of the y's */ %Let NX=3; /* No. of the x's */ %Let NPC=9; /* No. of yx correlations = NY*NX */ /***************************************************/ NV=&NY+&NX; /* No. of Variables */ CorY= PopCor[1:&NY,1:&NY]; /* Corr. among the y's */ CorX= PopCor[&NY+1:NV,&NY+1:NV]; /* Corr. among the x's */ CorYX= PopCor[&NY+1:NV,1:&NY]; /* Corr. betw. the y's & the x's */ do i=1 to ncol(CorYX); /* Corr. betw. the y's & the x's as a column*/ CorYXs=CorYXs//CorYX[,i]; end; %macro loop(NPC); %Do i=1 %to &NPC; /* Bi's Correlation matrices */ Cryx&i=I(2); Cryx&i[1,2]=CorYXs[&i,1]; Cryx&i[2,1]=CorYXs[&i,1]; %end; %mend loop; %loop (&npc); X=Rannor(Repeat(0,NS,&NX))*root(CorX); /* The X data matrix */ y=Rannor(Repeat(0,NS,&NY))*root(CorY); /* The Y data matrix */ DaXs=0*j(ns,&NX); %macro loop2 (NY); %Let k=0; %do j= 1 %to &NY; %do i=1 %to &NX; %Let c=%eval(&i+&K); %put c=&c; dat=(Y[,&j]||X[,&i])*(root(CrYX&c)); dat2=dat2||dat[,2]; %end; %Let k=&c; daXs=daXs+Dat2; free dat2; %end; %mend loop2; %loop2 (&NY ); daXs=daXs*(1/&NY); data=Y||daXs; /* The final data matrix */ eg=eigval(corr(DaXs)); CXs=(eg[<>,1]-1)/(&NX-1); /* The average Correlations among all x's */ eg=eigval(corr(Y)); CYs=(eg[<>,1]-1)/(&NY-1); /* The average Correlations among all y's */ Call=corr(data); /* Correlations among all data */ ca=call[1:&NY,(&NY+1):(&NY+&NX)]; print 'The Correlations between Xs and Ys',ca, 'The average Correlations among all Xs = ' CXs, 'The average Correlations among all Xs = 'CYs, 'The total correlation matrix of the data', call;