The PCA Procedure

OUTPUT Statement

  • OUTPUT OUT=CAS-libref.data-table
    <COPYVARS=(variables)>
    <keyword <=prefix>>…<keyword <=prefix>>
    ;

The OUTPUT statement creates a data table that contains observationwise statistics, which are computed after PROC PCA fits the model. If you do not specify a keyword, then only the principal component scores are included.

The variables in the input data table are not included in the output data table, in order to avoid data duplication for large data tables; however, variables that you specify in the COPYVARS= option are included.

You must specify the following option:

OUT=CAS-libref.data-table

names the output data table for PROC PCA to use. You must specify this option before any other options. 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 where the data table is to be stored, 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 output data table.

You can also specify the following syntax elements:

COPYVAR=variable
COPYVARS=(variables)

transfers one or more variables from the input data table to the output data table.

keyword <=prefix>

specifies a statistic to include in the output data table and optionally a prefix for naming the output variables. If you do not provide a prefix, the PCA procedure assigns a default prefix based on the type of statistic requested. For example, for the VAR statement variables x1 and x2, RESIDUAL produces two residual value variables, R_x1 and R_x2.

You can specify the following keywords to add statistics to the OUTPUT data table:

H

requests the approximate leverage. The default prefix is H.

STD

requests standardized (centered and scaled) VAR statement variable values for each VAR statement variable. The default prefix is Std.

STDSSE

requests the sum of squares of residuals for standardized VAR statement variables. The default prefix is StdSSE.

TSQUARE
T2

requests scaled sum of squares of score values. The default prefix is TSquare.

RESIDUAL
RESID
R

requests residuals for each VAR statement variable. The default prefix is R.

SCORE

requests principal component scores for each principal component. The default prefix is Score.

If you specify METHOD=EIG, the only valid keywords are RESIDUAL (if you also specify the PARTIAL statement; PROC PCA computes the residuals by predicting the VAR statement variables from the PARTIAL statement variables) and SCORE. Other keywords are ignored. The output variables that contain the principal component scores have mean 0 and a variance equal to the corresponding eigenvalue, unless you specify the STANDARD option to standardize the scores to unit variance. Also, if you specify the COV option, PROC PCA computes the principal component scores from the corrected variables or (if the NOINT option is specified) uncorrected variables rather than from the standardized variables.

The output variables that contain the requested statistic are named as follows, according to the keyword that you specify:

  • The keywords RESIDUAL and STD define an output variable for each VAR statement variable, so the variables that correspond to each VAR statement variable are named by appending the name of the VAR statement variable to the prefix. For example, if the model has the VAR statement variables x1 and x2, then RESIDUAL=R produces the variables R_x1 and R_x2.

  • The keyword SCORE defines an output variable for each principal component, so the variables that correspond to each successive component are named by appending the component number to the prefix. For example, if the model has three principal components, then SCORE=T produces the variables T1, T2, and T3.

  • The keywords H, STDSSE, and TSQUARE each define a single output variable, so the variable name matches the prefix.

Last updated: September 17, 2021