/*********************************************************** Principal Components Analysis to reduce dimensionality filename: principal_components.sas ************************************************************/ libname sasdata2 "d:\sasdata2"; options formdlim=" " pageno=1; title; OPTIONS FORMCHAR="|----|+|---+=|-/\<>*"; title "Simple Correlation Matrix"; proc corr data=sasdata2.baseball nomiss; var no_atbat no_hits no_home no_runs no_rbi; run; title "Original Linear Regression with Related Predictors"; proc reg data=sasdata2.baseball; model salary = no_atbat no_hits no_home no_runs no_rbi/ vif collin; run; quit; title "Use Proc Factor to Get Scree Plots"; proc factor data=sasdata2.baseball method=principal mineigen=1 scree ; where salary not=.; var no_atbat no_hits no_home no_runs no_rbi ; run; title "Use Proc Princomp to get Principal Components"; proc princomp data=sasdata2.baseball out=pcdata; where salary not=.; var no_atbat no_hits no_home no_runs no_rbi; run; title "Regression Analysis with First Principal Component as Predictor"; proc reg data=pcdata; model salary = prin1; run; quit;