BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
CBF
Fluorite | Level 6 CBF
Fluorite | Level 6
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
Fluorite | Level 6 CBF
Fluorite | Level 6

This worked! Thank you!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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