Hi there,
I wonder how to create SCREE plot by using principal component score only. Because metadata is not available for PCA, I only have PC score at hand. See following example.
example data:
options validvarname=any;
data Jobratings;
input 'Communication Skills'n 'Problem Solving'n
'Learning Ability'n 'Judgment Under Pressure'n
'Observational Skills'n 'Willingness to Confront Problems'n
'Interest in People'n 'Interpersonal Sensitivity'n
'Desire for Self-Improvement'n 'Appearance'n
'Dependability'n 'Physical Ability'n
'Integrity'n 'Overall Rating'n;
datalines;
2 6 8 3 8 8 5 3 8 7 9 8 6 7 7 4 7 5 8 8 7 6 8 5 7 6 6 7 5 6 7 5 7 8 6 3 7 7 5
8 7 5 6 7 8 6 9 7 7 7 9 8 8 9 9 7 9 9 9 9 7 7 9 8 8 7 8 8 8 8 8 9 8 9 7 8 9 9
8 8 8 7 9 9 8 9 9 9 9 8 8 9 8 9 9 7 9 8 8 7 7 9 4 7 9 8 4 6 8 8 8 6 3 5 6 5 2
3 3 5 1 4 3 1 1 3 8 9 8 8 8 8 7 9 5 7 6 8 6 7 7 6 5 5 7 8 9 9 4 4 6 3 9 7 9 7
8 8 9 9 9 8 8 9 8 9 8 9 7 6 7 6 6 6 7 7 5 9 8 8 8 8 7 7 6 6 7 6 7 6 7 7 9 6 7
7 6 3 8 3 9 9 3 2 5 8 8 8 5 6 2 5 7 3 8 8 1 1 2 8 4 9 1 5 8 8 8 7 9 9 6 6 7 9
7 9 8 8 8 7 9 7 9 8 7 7 9 5 9 6 7 9 8 7 9 8 9 9 7 5 8 7 8 7 9 8 9 9 8 8 9 9 8
8 8 9 8 8 8 8 7 8 8 7 6 7 6 5 6 8 7 6 7 7 8 8 8 8 9 8 8 8 8 9 9 8 9 9 8 8 8 8
9 9 8 8 8 7 8 9 8 8 6 7 6 4 6 5 7 7 3 8 4 7 7 6 7 8 7 7 8 7 8 8 7 9 9 9 9 7 7
6 8 8 8 8 6 6 7 6 8 6 6 7 6 7 6 7 8 6 6 5 7 4 6 7 7 6 3 3 4 2 4 4 7 6 6 6 4 8
5 5 6 5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 9 8 9 9 8 9 9 8 9 9 7 6 6 5 6 3 9 9 5 6 7 4 8 6
;
If you want to generate SCREE plot:
ods graphics on;
proc princomp data=Jobratings(drop='Overall Rating'n) out = jrpc;
run;
But what at my hand is data only with principal component score in jrpc, like
data jrpc;
set jrpc;
keep prin:;
run;
So, how can I use data only with PC score to generate SCREE plot, thanks!
Best,
Miller
For the scree plot all you need are the eigenvalues, and you can obtain these by computing the variance of the principal component scores. For example|:
proc means data=jrpc var;
var prin:;
output out=eigval var= /autoname;
run;
@MillerMac wrote:
Hi there,
I wonder how to create SCREE plot by using principal component score only. Because metadata is not available for PCA, I only have PC score at hand. See following example.
But what at my hand is data only with principal component score in jrpc, like
data jrpc; set jrpc; keep prin:; run;
So, how can I use data only with PC score to generate SCREE plot, thanks!
If I am understanding you properly, you want to create a SCREE plot using data set JRPC only? You can't. Unless you want to write your own code to replicate the calculations that are built into PROC PRINCOMP (and why would you want to do that?)
For the scree plot all you need are the eigenvalues, and you can obtain these by computing the variance of the principal component scores. For example|:
proc means data=jrpc var;
var prin:;
output out=eigval var= /autoname;
run;
You can get the output directly from PROC PRINCOMP. And then you don't have to create the scores and then write code to find the variances (which only works for some settings in PROC PRINCOMP anyway, if the scores are scaled to have a variance of 1 then you can't compute the eigenvalues from the scores).
ods ouptut eigenvalues=eigenvalues;
proc princomp ... ;
...
run;
This is exactly what I want, Thank you!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.