The PCA Procedure

PROC PCA Statement

  • PROC PCA <options>;

The PROC PCA statement invokes the PCA procedure. Optionally, it also identifies the input and output data sets, specifies the analyses to be performed, and controls displayed output. Table 15.3 summarizes the options available in the PROC PCA statement.

Table 15.3: PROC PCA Statement Options

Option

Description

Specify Data Sets

DATA=

Specifies the CAS input data table

OUTSTAT=

Specifies the CAS output data table that contains various statistics

Specify Details of Analysis

COV

Computes the principal components from the covariance matrix

METHOD=

Specifies the principal component extraction method to be used

N=

Specifies the number of principal components to be computed

NOINT

Omits the intercept from the model

PREFIX=

Specifies a prefix for naming the principal components

PARPREFIX=

Specifies a prefix for naming the residual variables

SINGULAR=

Specifies the singularity criterion

STD

Standardizes the principal component scores

VARDEF=

Specifies the divisor used to calculate variances and standard deviations

Specify ODS Graphics Details

PLOTS=

Specifies options that control the details of the plots


The following list provides details about these options.

COVARIANCE
COV

computes the principal components from the covariance matrix. If you omit this option, the correlation matrix is analyzed. The COV option causes variables that have large variances to be more strongly associated with components that have large eigenvalues, and it causes variables that have small variances to be more strongly associated with components that have small eigenvalues. You should not specify this option unless the units in which the variables are measured are comparable or the variables are standardized in some way.

DATA=CAS-libref.data-table

names the input data table for PROC PCA to use. The default is the most recently created data table. CAS-libref.data-table is a two-level name, where

CAS-libref

refers to a collection of information that is defined in the LIBNAME statement and includes the caslib, which includes a path to the data, and a session identifier, which defaults to the active session but which can be explicitly defined in the LIBNAME statement. For more information about CAS-libref, see the section Using CAS Sessions and CAS Engine Librefs.

data-table

specifies the name of the input data table.

METHOD=EIG | ITERGS<(iter-options)> | NIPALS<(nipals-options)> | RANDOM<(rand-options)>

specifies the principal component extraction method to be used. You can specify the following values:

EIG

requests eigenvalue decomposition.

ITERGS<(iter-options)>

requests the iterative method based on Gram-Schmidt orthogonalization (ITERGS) of Andrecut (2009). You can specify the following iter-options.

EPSILON=n

specifies the convergence criterion for the iterative method. By default, EPSILON=1E–12.

MAXITER=n

specifies the maximum number of iterations for the iterative method. By default, MAXITER=500.

NOCENTER

suppresses centering of the numeric variables to be analyzed. This option is useful if the analysis variables are already centered and scaled.

NOSCALE

suppresses scaling of the numeric variables to be analyzed. This option is useful if the analysis variables are already centered and scaled.

NIPALS<(nipals-options)>

requests the nonlinear iterative partial least squares (NIPALS) method. You can specify the following nipals-options.

EPSILON=n

specifies the convergence criterion for the iterative method. By default, EPSILON=1E–12.

MAXITER=n

specifies the maximum number of iterations for the iterative method. By default, MAXITER=500.

NOCENTER

suppresses centering of the numeric variables to be analyzed. This option is useful if the analysis variables are already centered and scaled.

NOSCALE

suppresses scaling of the numeric variables to be analyzed. This option is useful if the analysis variables are already centered and scaled.

RANDOM<(rand-options)>

requests the iterative method based on random projection (RANDOM) of Halko, Martinsson, and Tropp (2011). You can specify the following rand-options.

NITER=n

specifies the number of iterations. By default, NITER=1.

NOCENTER

suppresses centering of the numeric variables to be analyzed. This option is useful if the analysis variables are already centered and scaled.

NOSCALE

suppresses scaling of the numeric variables to be analyzed. This option is useful if the analysis variables are already centered and scaled.

SEED=n

specifies the random number generator seed. By default, SEED=1.

By default, METHOD=EIG. If you specify METHOD=ITERGS, METHOD=NIPALS, or METHOD=RANDOM, the following options in the PROC PCA statement are not supported: COV, NOINT, OUTSTAT=, PARPREFIX=, SINGULAR=, and STD.

N=number

specifies the number of principal components to be computed. If you specify METHOD=ITERGS, METHOD=NIPALS, or METHOD=EIG, the default is the number of variables. If you specify METHOD=RANDOM, the default is 1. The number must be an integer greater than or equal to 0. If N=0, the default is used.

NOINT

omits the intercept from the model. In other words, this option requests that the covariance or correlation matrix not be corrected for the mean. When you specify this option, the covariance matrix and, hence, the standard deviations are not corrected for the mean. If you want to obtain the standard deviations corrected for the mean, you can obtain them by using a procedure such as PROC MEANS in Base SAS.

If you specify this option and also create an OUTSTAT= data table, the data table’s type is UCORR or UCOV rather than CORR or COV. For more information, see the section OUTSTAT= Data Table.

OUTSTAT=CAS-libref.data-table

creates an output data table to contain means, standard deviations, number of observations, correlations or covariances, eigenvalues, and eigenvectors. CAS-libref.data-table is a two-level name, where CAS-libref refers to the caslib and session identifier, and data-table specifies the name of the output data table. For more information about this two-level name, see the DATA= option and the section Using CAS Sessions and CAS Engine Librefs.

If you specify the COV option, the data table’s type is COV or UCOV, depending on the NOINT option, and it contains covariances; otherwise, the data table’s type is CORR or UCORR, depending on the NOINT option, and it contains correlations. If you specify the PARTIAL statement, the OUTSTAT= data table also contains R-squares.

For more information about the OUTSTAT= data table, see the section OUTSTAT= Data Table.

PLOTS <(global-plot-options)> <= plot-request <(options)>>
PLOTS <(global-plot-options)> <= (plot-request <(options)> <…plot-request <(options)>>)>

controls the plots that are produced through ODS Graphics. When you specify only one plot-request, you can omit the parentheses around it. Some examples follow:

plots
plots=none
plots=(eigen profile)
plots(unpack)=scree

ODS Graphics must be enabled before you can request plots. For example:

ods graphics on;
proc pca plots=all;
   var x1--x10;
run;
ods graphics off;

You must specify the PLOTS option in order for the PCA procedure to produce plots. If you do not specify a plot-request, PROC PCA produces the scree plot by default.

You can specify the following global-plot-options:

UNPACKPANEL
UNPACK

suppresses paneling in the scree plot. By default, multiple plots can appear in an output panel. Specify UNPACKPANEL if you want each plot to appear in a separate panel. You can specify PLOTS(UNPACKPANEL) to unpack the default plots. You can also specify UNPACKPANEL as a suboption of the SCREE option (such as PLOTS=SCREE(UNPACKPANEL)).

You can specify the following plot-requests:

ALL

produces all appropriate plots. You can specify other options along with ALL; for example, to request all plots and unpack only the scree plot, specify PLOTS=(ALL SCREE(UNPACKPANEL)).

EIGEN <( UNPACKPANEL )>
EIGENVALUE <( UNPACKPANEL )>
SCREE <( UNPACKPANEL )>

produces the scree plot of eigenvalues and proportion variance explained. By default, both plots appear in the same panel. Specify PLOTS= SCREE(UNPACKPANEL) if you want each plot to appear in a separate panel.

NONE

suppresses the display of all plots.

PATTERNPROFILE
PROFILE

produces the pattern profile plot. Each component has its own profile. The Y-axis value represents the correlation between the variable (corresponding to the X-axis value) and the profiled principal component.

PREFIX=name

specifies a prefix for naming the principal components. By default, the names are Prin1, Prin2, …, Prinn. If you specify PREFIX=Abc, the components are named Abc1, Abc2, Abc3, and so on. The number of characters in the prefix plus the number of digits required to designate the variables should not exceed the current name length that is defined by the VALIDVARNAME= system option.

PARPREFIX=name
PPREFIX=name
RPREFIX=name

specifies a prefix for naming the residual variables in the OUTSTAT= data table. By default, the prefix is R_. The number of characters in the prefix plus the maximum length of the variable names should not exceed the current name length that is defined by the VALIDVARNAME= system option.

SINGULAR=p
SING=p

specifies the singularity criterion, where . If a variable in a PARTIAL statement has an R-square as large as when predicted from the variables listed before it in the statement, the variable is assigned a standardized coefficient of 0. By default, SINGULAR=1E–8.

STANDARD
STD

standardizes the principal component scores in the OUT= data table in the OUTPUT statement to unit variance. If you omit this option, the scores have a variance equal to the corresponding eigenvalue. Note that this option has no effect on the eigenvalues themselves.

VARDEF=DF | N | WDF | WEIGHT | WGT

specifies the divisor to be used to calculate variances and standard deviations. By default, VARDEF=DF. The following table displays the values and associated divisors:

Table 15.4: continued

Value

Divisor

Formula

 

DF

Error degrees of freedom

(before partialing)

  

(after partialing)

N

Number of observations

n

 

WEIGHT | WGT

Sum of weights

 

WDF

Sum of weights minus one

(before partialing)

  

(after partialing)


In the formulas for VARDEF=DF and VARDEF=WDF, p is the number of degrees of freedom of the variables in the PARTIAL statement, and i is 0 if you specify the NOINT option and 1 otherwise.

Last updated: December 21, 2018