data effluent; input x1-x4; boddiff=x1-x3; ssdiff=x2-x4; cards; 6 27 25 15 6 23 28 13 18 64 36 22 8 44 35 29 11 30 15 31 34 75 44 64 28 26 42 30 43 54 34 56 33 30 29 20 20 14 39 21 run; proc iml; use effluent; read all into x; x1=x[,1:2]; x2=x[,3:4]; n1=10; n2=10; p=2; ones1=j(n1,1,1); ones2=j(n2,1,1); xbar1=(1/n1)*x1`*ones1; xbar2=(1/n2)*x2`*ones2; xbardiff=xbar1-xbar2; resid1=x1-ones1*xbar1`; resid2=x2-ones2*xbar2`; s1=(1/(n1-1))*resid1`*resid1; s2=(1/(n2-1))*resid2`*resid2; print xbardiff s1 s2; spooled=((n1-1)/(n1+n2-2))*s1+((n2-1)/(n1+n2-2))*s2; tsquared=xbardiff`*inv((1/n1+1/n2)*spooled)*xbardiff; print tsquared; critvalue05=((n1+n2-2)*p/(n1+n2-p-1))*finv(.95,p,n1+n2-p-1); print critvalue05; tailprob=1-probf((n1+n2-p-1)/((n1+n2-2)*p)*tsquared,p,n1+n2-p-1); print tailprob; proc iml; use effluent; read all var{boddiff ssdiff} into x; n=10; p=2; ones=j(n,1,1); xbar=(1/n)*x`*ones; resid=x-ones*xbar`; s=(1/(n-1))*resid`*resid; print xbar s; tsquared=n*xbar`*inv(s)*xbar; print tsquared; critvalue05=((n-1)*p/(n-p))*finv(.95,p,n-p); print critvalue05; tailprob=1-probf((n-p)/((n-1)*p)*tsquared,p,n-p); print tailprob; run; quit; The SAS System 22:36 Wednesday, September 30, 2009 1 XBARDIFF S1 S2 -12 174.9 110.34444 75.566667 60.811111 8.6 110.34444 391.78889 60.811111 288.1 TSQUARED 10.763128 CRITVALUE05 7.6055941 TAILPROB 0.0186084 The SAS System 22:36 Wednesday, September 30, 2009 2 XBAR S -12 136.44444 -52.44444 8.6 -52.44444 198.26667 TSQUARED 11.446522 CRITVALUE05 10.032683 TAILPROB 0.0375398