******************************************;
*N OF FACTORS DECISION;
******************************************;
%MACRO FACT(ITEMS=_NUMERIC_);
PROC FACTOR SIMPLE;
VAR &ITEMS;
TITLE2 'PRINCIPAL COMPONENTS ANALYSIS';
TITLE3 'GUTTMAN''S WEAKEST LOWER BOUND';
TITLE4 'LOOKING FOR EIGENVALUES>=1';
RUN;
******************************************;
PROC FACTOR SIMPLE;
VAR &ITEMS;
PRIORS MAX;
TITLE2 'HIGHEST R COMMUNALITIES';
TITLE3 'GUTTMAN''S THIRD BOUND';
TITLE4 'LOOKING FOR EIGENVALUES>=0';
RUN;
******************************************;
PROC FACTOR NFACT=4 SIMPLE SCREE;
VAR &ITEMS;
PRIORS SMC;
TITLE2 'SQUARED MULTIPLE R COMMUNALITIES';
TITLE3 'GUTTMAN''S STRONGEST LOWER BOUND';
TITLE4 'SCREE PLOT FOR CATTEL''S SCREE TEST';
RUN;
******************************************;
*NOTE: STRONGEST>=THIRD>=WEAKEST;
******************************************;
PROC FACTOR METHOD=ML HEYWOOD N=4;
VAR &ITEMS;
TITLE2 'MAXIMUM LIKELIHOOD ANALYSIS WITH 4 FACTORS';
TITLE3 ;
TITLE4 ;
RUN;
******************************************;
%MEND FACT;
******************************************;

libname f1 'c:\projects';
data temp; set f1.merge1;
if rcode='P'; ** primary care cases only;
run;

TITLE1 "Factor analysis on Primary Care Cases -- provider related items"; RUN;
%fact(items=_17A _18A _19A _22A _23A _24A _25A _27A _28A _29A _30A);

endsas;

********************************************************************;
** Example of 4 factor solution: creating factors and correlation with items;
********************************************************************;
*FACTOR ROTATION;
********************************************************************;
PROC FACTOR data=temp NFACT=4 PREROTATE=VARIMAX ROTATE=PROMAX REORDER OUT=FACTOUTA;
var _17A _18A _19A _22A _23A _24A _25A _27A _28A _29A _30A;
PRIORS SMC;
TITLE1 'OBLIQUE PROMAX ROTATION -- 4 FACTOR SOLUTION';
TITLE2 'COMMON FACTOR ANALYSIS';
TITLE3 'SQUARED MULTIPLE CORRELATIONS AS PRIOR COMMUNALITIES ESTIMATES';
RUN;
********************************************************************;