SAS Procedures

Help using Base SAS procedures
BookmarkSubscribeRSS Feed
mgilbert
Obsidian | Level 7

I started with a small data set (under 20 variables) and conducted truncation, trimming, and imputing. I finally prepped the data where I wanted it to be, and ran PROC PRINCOMP. I then used the results to run a regression model where my response variable (TARGET_WINS) = specified principal components (and only principal components).

 

I'm now tasked with applying my model to another data set and scoring it. This new data set is a clone of my original data set, except it has fewer observations and no response variable. If this were a "normal" regression and I did not use principal components, I could construct the beta coefficients from the parameter estimates, and simply substitute the variables in the new data set to create the predicted values.

 

But (as far as I know) since principal components are relative to the other data in the data set, I have absolutely no clue how to go about this. I can create the new principal components in the new data set, but since there's no response variable, I can't model it via PROC REG and score the predicted values.

 

I've taken a look at PROC SCORE, but have not had much luck. I have stored the OUTSTAT from PROC PRINCOMP in the original data set, and reduced it to only have principal components used in the regression model (from here and here). Any thoughts?

 

Michael

3 REPLIES 3
PGStats
Opal | Level 21

Use ODS to get the eigenvectors and then proc score to get the component scores. Here is an example

 

/* Keep the first 50 observations for scoring. 
 Compute the two first principal components on the rest */
proc princomp data=sashelp.cars(firstobs=51) n=2 cov;
var engineSize cylinders horsepower weight wheelbase length;
ods output Eigenvectors=EV;
run;

proc transpose data=ev out=evTransposed;
var Prin1 Prin2;
id Variable;
run;

data prinScore;
set evTransposed;
_TYPE_ = "SCORE";
run;

/* Compute the first two component scores for the 
 first 50 observations */
proc score data=sashelp.cars(obs=50) score=prinScore out=scoredCars; 
run;
PG
mgilbert
Obsidian | Level 7

Thanks - I'll give this a shot tonight.

 

Less on the procedure but more on the theory side... Once I get the new data scored, it is then appropriate to hand-code the regression equation using the beta coefficients from the old data, and substituting the new scored data in? Greatly appreciate the help.

 

Michael

Rick_SAS
SAS Super FREQ

If "beta coefficients from the old data" means "beta coefficients from the regression that uses the prinipal components as explanatory variables," then the answer is yes.  Remember that the prinipal components are just linear combinations of your original explanatory variables. When you score the new data, you are creating coordinates in a new coordinate system in which the prinipal components replace the usual (x,y,z,...) coordinates. Mathematically, this is called a change of basis.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3190 views
  • 1 like
  • 3 in conversation