Published on :
Statistical CREATION_INTERNE

Factor Analysis Example (PROC FACTOR)

This code is also available in: Deutsch Español Français
Awaiting validation
The script begins by creating a dataset named `SocioEconomics` containing indicators for different localities (Population, School, etc.). Then, it executes the `PROC FACTOR` procedure three times to perform a factor analysis. Each execution uses the maximum likelihood method (`method=ml`) but varies the number of factors to extract (1, 2, then 3), allowing for model comparison. The `heywood` option is used to handle cases where communalities exceed 1.
Data Analysis

Type : CREATION_INTERNE


The `SocioEconomics` data is created directly in the code via a DATA step with a `datalines` statement. It does not come from SASHELP or an external source.

1 Code Block
DATA STEP Data
Explanation :
This block creates the `SocioEconomics` table in memory. The data is included directly in the script via the `datalines` statement, a common method for small example datasets.
Copied!
1DATA SocioEconomics;
2 INPUT Population School Employment Services HouseValue;
3 DATALINES;
45700 12.8 2500 270 25000
51000 10.9 600 10 10000
63400 8.8 1000 10 9000
73800 13.6 1700 140 25000
84000 12.8 1600 140 25000
98200 8.3 2600 60 12000
101200 11.4 400 10 16000
119100 11.5 3300 60 14000
129900 12.5 3400 180 18000
139600 13.7 3600 390 25000
149600 9.6 3300 80 12000
159400 11.4 4000 100 13000
16;
2 Code Block
PROC FACTOR
Explanation :
This procedure performs a first factor analysis on the `SocioEconomics` table. `method=ml` specifies the use of the maximum likelihood method. `n=1` constrains the model to extract only one factor. `heywood` allows the process to continue even if a communality is greater than 1.
Copied!
1title3 'Maximum Likelihood Factor Analysis with One Factor';
2PROC FACTOR
3DATA=SocioEconomics method=ml heywood n=1;
4RUN;
5 
3 Code Block
PROC FACTOR
Explanation :
Similar to the previous one, this factor analysis tests a two-factor model (`n=2`) to evaluate whether a more complex structure better explains the data variance.
Copied!
1title3 'Maximum Likelihood Factor Analysis with Two Factors';
2PROC FACTOR
3DATA=SocioEconomics method=ml heywood n=2;
4RUN;
5 
4 Code Block
PROC FACTOR
Explanation :
This last analysis extends the model to three factors (`n=3`), completing the comparison of factorial models to determine the most relevant underlying structure.
Copied!
1title3 'Maximum Likelihood Factor Analysis with Three Factors';
2PROC FACTOR
3DATA=SocioEconomics method=ml heywood n=3;
4RUN;
5 
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : S A S S A M P L E L I B R A R Y