BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
CBF
Calcite | Level 5 CBF
Calcite | Level 5
I want to produce a scree plot that I can easily paste into a word document that has an x-axis with only 15 factors. I have tried multiple methods to do this. When I tried ODS RTF, the files were blank. I finally settled on using ODS HTML, but I have not been able to adjust the x-axis on my plot. I tried using a template, but I don't think it is being applied in PROC FACTOR. I tried using SGRENDER, but the images were blank. When I do produce an image, with the code below, the x-axis shows 60 factors, so it is difficult to see where the elbow is. Any help would be greatly appreciated!

PROC TEMPLATE; 
DEFINE STATGRAPH SCREEPLOT; 
NOTES "SCREE PLOT FOR EXTRACTED EIGENVALUES";
BEGINGRAPH / DESIGNWIDTH=DEFAULTDESIGNHEIGHT; 
ENTRYTITLE "EIGENVALUE ((*ESC*){UNICODE LAMBDA}) PLOT"; 
LAYOUT OVERLAY / YAXISOPTS=(LABEL="(*ESC*){UNICODE LAMBDA}") 
XAXISOPTS=(LABEL="FACTOR NUMBER" 
LINEAROPTS=(TICKVALUELIST=(1 2 3 4 5 6 7 8 9 10))); 
SERIESPLOT Y=EIGENVALUE X=NUMBER / DISPLAY=ALL; 
ENDLAYOUT; ENDGRAPH; END; RUN;
 
ODS GRAPHICS ON ; 
%LET OUTDIR=[PATH] ;
ODS HTML PATH="&OUTDIR" (URL=NONE)
BODY='BODY2.HTML' 
/*CONTENTS='CONTENTS2.HTML'
FRAME='FRAME2.HTML' */ ;
PROC FACTOR DATA = DATA METHOD=PRINCIPAL PRIORS=SMC RESIDUAL  
ROTATE=VARIMAX OUTSTAT=OUTSTAT 
PLOTS(UNPACK)=SCREE REORDER  ;
  VAR &VARS ; 
RUN; 
ODS HTML CLOSE ;
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

You could save these data firstly ,afterwards polt it by PROC SGPLOT.

ods select none;
ods output ScreePlot=ScreePlot;
PROC FACTOR DATA = sashelp.heart METHOD=PRINCIPAL PRIORS=SMC RESIDUAL  
ROTATE=VARIMAX OUTSTAT=OUTSTAT 
PLOTS(UNPACK)=SCREE REORDER  ;
  VAR _numeric_ ; 
RUN; 
ods select all;


%let n=6;  /*the number of factors you want to display*/
proc sgplot data=ScreePlot(where=(number<=&n.));
series x=number y=Eigenvalue/markers;
run;

Ksharp_0-1712284711376.png

 

Or you could check the next graph "the explained variance"  to find elbow point ?

Ksharp_1-1712284861249.png

 

 

View solution in original post

3 REPLIES 3
ballardw
Super User

Did you look at the Proc Factor option NPLOTS= to limit the number of factors plotted?

Ksharp
Super User

You could save these data firstly ,afterwards polt it by PROC SGPLOT.

ods select none;
ods output ScreePlot=ScreePlot;
PROC FACTOR DATA = sashelp.heart METHOD=PRINCIPAL PRIORS=SMC RESIDUAL  
ROTATE=VARIMAX OUTSTAT=OUTSTAT 
PLOTS(UNPACK)=SCREE REORDER  ;
  VAR _numeric_ ; 
RUN; 
ods select all;


%let n=6;  /*the number of factors you want to display*/
proc sgplot data=ScreePlot(where=(number<=&n.));
series x=number y=Eigenvalue/markers;
run;

Ksharp_0-1712284711376.png

 

Or you could check the next graph "the explained variance"  to find elbow point ?

Ksharp_1-1712284861249.png

 

 

CBF
Calcite | Level 5 CBF
Calcite | Level 5

This worked! Thank you!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 663 views
  • 2 likes
  • 3 in conversation