Programming the statistical procedures from SAS

I'm trying to run a factor analysis but I'm having some trouble

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

I'm trying to run a factor analysis but I'm having some trouble

I imported the data as followed:

 

/* Generated Code (IMPORT) */
/* Source File: Hatco x1-x7.txt */
/* Source Path: /home/tmaciver7840/my_content */
/* Code generated on: Friday, June 24, 2016 3:56:21 PM */

%web_drop_table(WORK.IMPORT4);


FILENAME REFFILE "/home/tmaciver7840/my_content/Hatco x1-x7.txt" TERMSTR=CR;

PROC IMPORT DATAFILE=REFFILE
DBMS=tab
OUT=WORK.IMPORT4;
GETNAMES=YES;
RUN;

PROC CONTENTS DATA=WORK.IMPORT4; RUN;


%web_open_table(WORK.IMPORT4);

 

I'm good up to this point. Now I just need a little help with running a factor analysis. I appreciate any guidance. Thank you.


Accepted Solutions
Solution
‎06-24-2016 05:33 PM
SAS Super FREQ
Posts: 3,837

Re: I'm trying to run a factor analysis but I'm having some trouble

Posted in reply to Tommac72584

There are many kinds of factor analysis. The simplest is probably the principal component analysis.  The documentation for PROC FACTOR has a Getting Started example and four other helpful examples. A basic call might look like this:

 

ods graphics on;
proc factor data=import4 corr n=4 score outstat=ScoreOut
     method=prin rotate=varimax plots=all;
var x1-x7;
run;

If you want to produce factor scores, you can use PROC SCORE to score the model and use PROC SGPLOT to plot the results:

 

 

proc score data=import4 score=ScoreOut out=FactorScores;
   var x1-x7;
   ID ID;
run;

proc sgplot data=FactorScores;
   scatter x=Factor1 y=Factor2 / datalabel=ID;
   xaxis grid;
   yaxis grid;
   refline 0 / axis=x; refline 0 / axis=y; 
run;

View solution in original post


All Replies
Solution
‎06-24-2016 05:33 PM
SAS Super FREQ
Posts: 3,837

Re: I'm trying to run a factor analysis but I'm having some trouble

Posted in reply to Tommac72584

There are many kinds of factor analysis. The simplest is probably the principal component analysis.  The documentation for PROC FACTOR has a Getting Started example and four other helpful examples. A basic call might look like this:

 

ods graphics on;
proc factor data=import4 corr n=4 score outstat=ScoreOut
     method=prin rotate=varimax plots=all;
var x1-x7;
run;

If you want to produce factor scores, you can use PROC SCORE to score the model and use PROC SGPLOT to plot the results:

 

 

proc score data=import4 score=ScoreOut out=FactorScores;
   var x1-x7;
   ID ID;
run;

proc sgplot data=FactorScores;
   scatter x=Factor1 y=Factor2 / datalabel=ID;
   xaxis grid;
   yaxis grid;
   refline 0 / axis=x; refline 0 / axis=y; 
run;
Occasional Contributor
Posts: 9

Re: I'm trying to run a factor analysis but I'm having some trouble

Perfect. Thank you Rick. 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 307 views
  • 1 like
  • 2 in conversation