The `eig` action performs Principal Component Analysis (PCA) using the eigenvalue decomposition method. It is a fundamental statistical technique used for dimensionality reduction and data exploration. By analyzing the covariance or correlation matrix of numeric variables, it calculates eigenvalues and eigenvectors to transform the original correlated variables into a smaller set of uncorrelated variables called principal components. This action supports weighting, frequency variables, and can generate output tables containing component scores and statistical summaries.
| Parameter | Description |
|---|---|
| table | Specifies the settings for the input CAS table to be analyzed. |
| inputs | Specifies the list of numeric variables to use for the analysis. If omitted, all numeric variables are used. |
| n | Specifies the number of principal components to be computed. If set to 0, all components are computed. |
| cov | If set to TRUE, computes the principal components from the covariance matrix. If FALSE (default), the correlation matrix is used. |
| std | If set to TRUE, standardizes the principal component scores in the output table to unit variance. |
| output | Specifies the output table to contain observation-wise statistics, such as component scores. |
| outStat | Specifies the output table to contain statistics like means, standard deviations, eigenvalues, and eigenvectors. |
| noInt | If set to TRUE, suppresses the intercept (fits the model through the origin). |
| prefix | Specifies a prefix string for naming the principal component variables (default is 'Prin'). |
| freq | Specifies a numeric variable that contains the frequency of occurrence for each observation. |
| weight | Specifies a numeric variable to use as a weight for performing a weighted analysis. |
| code | Generates SAS DATA step code to compute predicted values (scores) based on the fitted model. |
| store | Saves the model fit information to a CAS table (analytic store) for use in scoring. |
Loads the sample 'Iris' dataset into a CAS table named 'iris' in the 'casuser' library.
| 1 | PROC CAS; |
| 2 | /* Load SASHELP.IRIS into CAS memory */ |
| 3 | DATA casuser.iris; |
| 4 | SET sashelp.iris; |
| 5 | RUN; |
| 6 | QUIT; |
Performs a standard Principal Component Analysis on the Iris dataset to extract the top 2 components based on the correlation matrix.
| 1 | PROC CAS; |
| 2 | pca.eig / |
| 3 | TABLE={name="iris", caslib="casuser"} |
| 4 | inputs={"SepalLength", "SepalWidth", "PetalLength", "PetalWidth"} |
| 5 | n=2; |
| 6 | RUN; |
Performs PCA using the covariance matrix, standardizes the output scores, creates specific output tables for statistics and scores, and saves the scoring code.
| 1 | PROC CAS; |
| 2 | pca.eig / |
| 3 | TABLE={name="iris", caslib="casuser"} |
| 4 | /* Use specific numeric inputs */ |
| 5 | inputs={"SepalLength", "SepalWidth", "PetalLength", "PetalWidth"} |
| 6 | /* Use Covariance matrix instead of Correlation */ |
| 7 | cov=true |
| 8 | /* Standardize scores to unit variance */ |
| 9 | std=true |
| 10 | /* Custom prefix for component names */ |
| 11 | prefix="PC" |
| 12 | /* Output table for Eigenvalues/Vectors */ |
| 13 | outStat={casOut={name="eigen_stats", caslib="casuser", replace=true}} |
| 14 | /* Output table for Scores, copying the Species variable */ |
| 15 | OUTPUT={casOut={name="iris_scores", caslib="casuser", replace=true}, |
| 16 | score="Score", |
| 17 | copyVars={"Species"}} |
| 18 | /* Generate scoring code */ |
| 19 | code={casOut={name="score_code", caslib="casuser", replace=true}}; |
| 20 | RUN; |
A retail bank wants to segment its customer base for a new credit card offer. They have multiple correlated variables related to spending habits (groceries, travel, entertainmen...
A manufacturing plant monitors heavy machinery using dozens of sensors. They need to analyze the raw variance (Covariance) rather than correlation, because the magnitude of vibr...
Researchers are analyzing gene expression data that has been pre-normalized to be centered around zero. They want to perform PCA without an intercept (forcing the model through ...