** Program to compute eigenvalues and eigenvectors of (X'X) matrix (after normalization) **; options ls=80 nocenter; ** Read in X matrix **; data indat; input obs x1 x2 x3 x4 x5; cards; 1 1.02608 1.02461 1.00589 1.00290 1.04109 2 1.01259 1.01725 -0.97663 -0.97464 -0.99381 3 1.00222 1.00396 1.03925 1.02450 1.01480 4 1.00835 1.01537 -0.98868 -0.97407 -0.99746 5 -0.96519 -0.98171 1.04362 1.01111 1.04390 6 -0.95359 -0.96563 -0.97973 -0.96899 -0.97741 7 -0.95045 -0.99967 1.04098 1.02708 1.00034 8 -0.95349 -0.96943 -0.95564 -0.95102 -0.98772 ; ** Enter SAS matrix processing utility **; proc iml; ** Cutoff point for calling an eigenvalue close to 0 **; evcut = 0.001; ** Transfer in X matrix **; use indat var {x1 x2 x3 x4 x5}; read all; n = nrow(x1); x = j(n,1)||x1||x2||x3||x4||x5; ** Normalize **; do ic = 1 to ncol(x); x[,ic] = x[,ic] / sqrt(ssq(x[,ic])); end; ** Compute **; xtx = x`*x; call eigen(evals,evecs,xtx); v = evecs; vt = evecs`; xv = x*v; xvtil = xv; do i = 1 to ncol(x); if (evals[i,] <= evcut) then xvtil[,i] = j(n,1,0); end; xtil = xvtil*vt; ** Print out results **; print xtx; print evals vt; print x; print v; print xv; print xvtil; print xtil;