BookmarkSubscribeRSS Feed
Anon794
Calcite | Level 5

Hi All -

I am new to SAS so sorry if my questions are basic and thank you in advance for taking the time. Purely to experiment with the software, I am using a sample data file of random numbers - SampleData.csv - Google Drive

As you can see in this file, the first column lists the observation number (range 1-100), second column is a response variable called 'ResponseVar', followed by 10 columns labeled 'PredictorN' where N=(1,10)

Now in the R software package, I can perform a principal component analysis on the predictor variables to obtain my 10 eigenvalues, a 10x10 rotation matrix of eigenvectors, and my 100x10 transformed matrix. For reference, I obtain this in R with the prcomp function in the stats library.

I am trying to replicate this in SAS University Edition (I'm running thru Oracle's VirtualBox on my MacBook) using the following program:

ods graphics on;

data getdata;

    infile "/folders/myfolders/Sample.csv"

    Firstobs=2 LRECL=1000000000 DLM=',';

    input

    TrialNum ResponseVar Predictor1 Predictor2 Predictor3 Predictor4 Predictor5 Predictor6 Predictor7 Predictor8 Predictor9 Predictor10

    ;

run;

data regressors; set getdata;

    drop TrialNum ResponseVar;

       

/*    Debug code

proc print data=regressors; run;

*/

proc factor data=regressors

    simple corr

    Mineigen=0 /*Retain all factors*/

    All /*Display all optional data*/

    ;

run;

The factor proc step indicates it has read and used 100 records, it calculates the 10 eigenvalues, it generates the 10x10  eigenvectors but it does not generate my 100x10 matrix of transformed data. I suppose I could copy the output of the program and then run a new program to manually generate the transformed data by multiplying each observation by the transpose of the eigenmatrix.

But my questions are:

1) is there a pre-programmed routine to generate the transformed data for the 100 observations in terms of principal components

AND

2) if I wanted to do this manually, is there a way to grab the output of the 'proc factor data=regressors' step so that I can use the eigenvector matrix for computation rather than copying the output, reading into a new program, etc. ?

Thanks again to all in advance.

2 REPLIES 2
gergely_batho
SAS Employee

Hi,

1. Specify out= option on the proc factor statement.

http://support.sas.com/documentation/cdl/en/statug/63962/HTML/default/viewer.htm#statug_factor_sect0...

2. Specify outstat= option on hte proc factor statemnt, then use proc score. Example here:

SAS/STAT(R) 9.3 User's Guide

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 636 views
  • 0 likes
  • 2 in conversation