BookmarkSubscribeRSS Feed
PhilG
Fluorite | Level 6

Hello!

I'm having a terribly hard time trying to import a matrix of polychoric correlations for use in a factor analysis. I'm really not sure what I'm doing wrong, because I'm following the steps I've seen on various websites. The farthest I get is creating a temp file that only has the names of the variables along the top, but none of the cells are filled in. Here's the syntax I've been using. Perhaps someone can tell me where I'm going wrong.

Step 1: creating the matrix:

corr data= Work.temp00 polychoric out= WORK.temp01; var 1_1 q1_2 q1_3 q1_4 q1_5 q1_6 q1_7 q1_8 q1_9 q1_10 q1_11 q1_13 etc.; run;

I then export this temp file into a csv file (I won't include the syntax because it everything works up to this point.

Step 2: trying to imput the correlation matrix

Data= temp02 (type=corr);

infile 'poly.csv';

input _name_ $ q1_1 q1_2 q1_3 q1_4 q1_5 q1_6 q1_7 q1_8 q1_9 q1_10 q1_11 q1_13 etc.; run;

The result is a temp file with a header row with "type" and "name" in the first two columns followed by, as I said, the variable names in the header row, but nothing in the cells? Nevertheless, the next step I'm trying to do is this:

Step 3: factor analysis

Proc factor data=temp02; method=prinit n=2 [note that I'm also not sure what the "n=2" is all about. should this be the actual number of observations?)rotate=promax scree; run;

Any advice would be most welcome! Thank you!

5 REPLIES 5
Reeza
Super User

Why export out to a file and then bring it back in?

Skip step2 entirely and then go to step 3 and use the temp01 as your data input.

Also, work through an example for proc factor before trying this so you understand the options.

SAS/STAT(R) 9.22 User's Guide

PhilG
Fluorite | Level 6

Thank you for the reply. Unfortunately, I've tried that several times and I get this message:

NOTE: N not equal across variables in data set WORK.TEMP01. This may not be appropriate. The smallest value will be used.

ERROR: CORR matrix incomplete in data set WORK.TEMP01.

NOTE: The SAS System stopped processing this step because of errors.

Reeza
Super User

The correlation output from proc corr gives some extra statistics, such as N, Mean etc.

Filter those out first to get a true correlation matrix.

Then input to proc factor, add in a TYPE variable with a value called CORR to specify a correlation input.

You also have your semicolons in the wrong place. Anyways, hopefully this gets you on to working with the proc factor procedure instead of dealing with input data.

See the following to determine what settings you want:

http://www.math.wpi.edu/saspdf/stat/chap26.pdf

proc corr data=sashelp.iris out=corrMatrix;

var petalwidth petallength sepalwidth sepallength;

run;

proc print data=corrMatrix;

run;

data corrMatrix2;

    set corrMatrix;

    where _Type_='CORR';

    TYPE="CORR";

    drop _type_ _name_;

run;

ods graphics on;

proc factor data=corrMatrix2

   rotate=promax

   outstat=fact_all

   plots=scree;

run;

ods graphics off;

lily2190
Calcite | Level 5

I recognize this error. You need to look closer of your correlation matrix. Some pairs of your variables may not have their correlation calculated and you got a empty cells in the matrix which SAS says it is incomplete matrix.

niam
Quartz | Level 8

Use proc corr to create the correlation matrix and export it directly to  another SAS dataset and then use that dataset as your ut for proc calis:

Here is the example:

ods listing close;

proc corr data=survey OUTPLC=surveyplc ;

var V1-V12;

run;

ods listing;

proc calis data=surveyplc

;

lineqs

....;

std

.....;

cov

.....

var;

  V1-V12;

run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 3171 views
  • 2 likes
  • 4 in conversation