/* This routine performs a principal components analysis using PROC IML. In general, those wishing to do a basic PCA should use PROC PRINCOMP. This IML version, however, can be used more readily in studies that need specific results of the PCA to determine subsequent steps in the analysis. NOTE: the code here assumes aligned landmark data are used, thereby computing eigenvectors from the covariance matrix. This is not appropriate for all types of data. */ proc iml; use two; read all into X; N=nrow(X); LM=ncol(X); meanX=X[+,]/N; Xbar=shape(meanX,N,LM); Dif=X-Xbar; S=(Dif`*Dif)/(N-1); call eigen(val,vec,S); scores=vec`*Dif`; scores=scores`; var=val[+,]; abort;