BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lmpsumagpang
Calcite | Level 5

Is it possible to run a Factor Analysis on a pre-defined correlation matrix? From what I know, if you run PROC FACTOR, the first thing SAS does is create a correlation matrix but since the dataset I have is already the correlation matrix, wouldn't that mess up the whole process?

 

My code:

/* check if correlation coefficients are the same as the original coefficients in the dataset */
proc corr data=dataset outs=datacorr; run;
 
/* Factor Analysis */
ods graphics on;
proc factor data=datacorr r=v n=3 plots=loadings;
run;
ods graphics off;
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Rough outline of code

 

PROC IMPORT datafile = 'whatever.xlsx' out=a dbms=excel;

run;

 

data corr(type=corr);

    set a;

run;

 

proc factor data=corr;

 ...

run;

 

DISCLAIMER: this may not work on correlation data sets stored in Excel, as there's no standard that I know of for correlation matrices in Excel being formatted/laid out the same as a PROC CORR output data set. You can't know until you try it.

--
Paige Miller

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

This is a great example of why you should look at the documentation.

 

A correlation data set (with option TYPE=CORR) is valid input to PROC FACTOR and PROC PRINCOMP. Since your output is from PROC CORR, there should be no issue using it in PROC FACTOR or PROC PRINCOMP. Details are here: https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=statug&docsetTarget=statu...

--
Paige Miller
lmpsumagpang
Calcite | Level 5

Thanks but I was wondering why I have to compute for a new correlation matrix when my initial dataset is already a correlation matrix. Would the analysis significantly change?

 

Is there a way where I can import the initial dataset and dictate it's TYPE (CORR) so SAS won't have to compute a new correlation matrix from it?

PaigeMiller
Diamond | Level 26

@lmpsumagpang wrote:

Thanks but I was wondering why I have to compute for a new correlation matrix when my initial dataset is already a correlation matrix. Would the analysis significantly change?


As far as I know, you don't have to compute a new correlation data set if you have PROC CORR output. That's my understanding, and the link I gave seems to say that as well. This is what it says:

 

The data set created by the CORR procedure is automatically given the TYPE=CORR data set option, so you do not have to specify TYPE=CORR.

--
Paige Miller
lmpsumagpang
Calcite | Level 5

Please disregard the proc corr code that I shared in my inquiry. Smiley Embarassed

 

The original data set that I've imported (from an excel file) is already a correlation matrix. Making a proc factor function will result to SAS making a new correlation matrix out of it which might affect my analysis. Is there a way where I can import the excel file and set it as TYPE=CORR?

 

Thanks for your immediate response and I appreciate all the help!

PaigeMiller
Diamond | Level 26

Rough outline of code

 

PROC IMPORT datafile = 'whatever.xlsx' out=a dbms=excel;

run;

 

data corr(type=corr);

    set a;

run;

 

proc factor data=corr;

 ...

run;

 

DISCLAIMER: this may not work on correlation data sets stored in Excel, as there's no standard that I know of for correlation matrices in Excel being formatted/laid out the same as a PROC CORR output data set. You can't know until you try it.

--
Paige Miller
lmpsumagpang
Calcite | Level 5

Thank you! It worked fine. Smiley Happy 

The excel file had the same format and data type as the format using the proc corr statement

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 1119 views
  • 0 likes
  • 2 in conversation