data headache; input x1-x4; cards; 81 64 72 75 58 48 60 58 65 59 59 60 84 62 85 91 86 75 75 80 72 60 48 61 89 85 80 74 run; proc iml; use headache; read all into x; n=7; q=4; ones=j(n,1,1); xbar=(1/n)*x`*ones; resid=x-ones*xbar`; s=(1/(n-1))*resid`*resid; print xbar s; c={1 -1 0 0, 0 1 -1 0, 0 0 1 -1}; tsquared=n*(c*xbar)`*inv(c*s*c`)*(c*xbar); print tsquared; critvalue05=((n-1)*(q-1)/(n-q+1))*finv(.95,q-1,n-q+1); print critvalue05; tailprob=1-probf((n-q+1)/((n-1)*(q-1))*tsquared,q-1,n-q+1); print tailprob; run; quit; The SAS System 09:10 Tuesday, September 29, 2009 1 XBAR S 76.428571 136.28571 120.64286 117.28571 117.19048 64.714286 120.64286 143.2381 90.97619 70.595238 68.428571 117.28571 90.97619 173.61905 142.85714 71.285714 117.19048 70.595238 142.85714 149.2381 TSQUARED 107.23672 CRITVALUE05 29.66122 TAILPROB 0.0051702