<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/platform.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d25388941\x26blogName\x3dThrough+Foreign+Eyes\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttps://wildthoughtsfaq.blogspot.com/search\x26blogLocale\x3den\x26v\x3d2\x26homepageUrl\x3dhttps://wildthoughtsfaq.blogspot.com/\x26vt\x3d-9059364863595816560', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>
MWave 468x60

Lakaw is a journey is a step is a move. I love to travel around the world and this is my travel and travel gadget site. Welcome and Enjoy!

4 comments | Friday, May 02, 2008

Principal Components Analysis (PCA) - SAS statistics code.

The basic objective of a PCA is to discover new variables called principal components, which are in decreasing order of importance, so that

1. They are uncorrelated.
2. The first principal component accounts for as much of the variability in the data as possible.
3. Each succeeding component accounts for as much of the remaining variability as possible.

Here is a SAS program for Principal Components Analysis (PCA). You can run the code with the given data below and interpret the results.

******
dm log 'clear';
dm output 'clear';
options nodate;

data PCA;
input X1 X2 X3 X4 X5 X6 X7 X8;
datalines;
6 7 2 5 8 7 8 8

9 10 5 8 10 9 9 10

7 8 3 6 9 8 9 7

5 6 8 5 6 5 9 2

6 8 8 8 4 4 9 5

7 7 7 6 8 7 10 5

9 9 8 8 8 8 8 8

9 9 9 8 9 9 8 8

9 9 7 8 8 8 8 5

4 7 10 2 10 10 7 10

4 7 10 0 10 8 3 9

4 7 10 4 10 10 7 8

6 9 8 10 5 4 9 4

8 9 8 9 6 3 8 2

4 8 8 7 5 4 10 2
6 9 5 7 8 9 8 9

8 7 7 7 9 5 8 6

6 8 8 4 8 8 6 4

6 7 8 4 7 8 5 4

4 8 7 8 8 9 10 5

;

PROC PRINCOMP DATA=PCA OUT=PCSCORES COVARIANCE;
VAR X1--X8;
title 'Principal Component Analysis';
RUN;


PROC FACTOR DATA=PCA scree;
VAR X1--X8;

TITLE2'Scree Plot of Eigenvalues';
RUN;

PROC PRINT DATA=PCSCORES;
VAR PRIN1 PRIN2 PRIN3;
TITLE2 'VALUES OF THE FIRST THREE PRINCIPAL COMPONENT SCORES';
RUN;


proc univariate data=pcscores plot;
var prin1 prin2;
TITLE2 'Univariate Analysis on the first two Principal Components';

run;

proc gplot DATA=PCSCORES;
plot prin2*prin1;
TITLE2 'A Scatter Plot of the First Two Principal Component Scores';

run;

quit;

*****
If you would like to have the SAS interpretation of PCA, please leave me a comment.

Labels:

4 Comments:

Anonymous Anonymous said...

I would like to understand how the PCA scores are calculated (in detail) for a correlation option.

August 26, 2008 10:53 AM

 
Anonymous Anonymous said...

I'm wondering if you could/can answer this question regarding SAS coding.

I've done a principle components analysis (PROC PRINCOMP) and now want to get a factor score. I can't find any SAS code anywhere on how to do this? (Do I have to do proc factor and then proc score? Or can I just do a proc score after proc princomp? I'm doing something wrong because it isn't working. Thanks in advance.

November 09, 2008 11:24 AM

 
Anonymous Anonymous said...

how do you store these prin values to use in proc logistic?

March 20, 2009 3:12 PM

 
Anonymous Anonymous said...

I want to find out the climatological regions based on the rainfall data using principal component analysis (PCA) i have almost 71 meteorological stations for 30 years climatological records. So i would like to have the SAS interpretation of PCA.And also to know how its works.


St.Petersburg

April 25, 2009 7:32 PM

 

<< Home

More Interesting Stories

Related Posts with Thumbnails