The correlation action computes Pearson product-moment correlations. This is a fundamental statistical analysis to assess the linear relationship between two or more continuous variables. It produces a correlation matrix, which displays the correlation coefficient for each pair of variables. This coefficient ranges from -1 (perfect negative correlation) to +1 (perfect positive correlation), with 0 indicating no linear correlation.
| Parameter | Description |
|---|---|
| alpha | When set to True, computes Cronbach's coefficient alpha. |
| attributes | Specifies the variable attributes. |
| casOut | Specifies the settings for an output table. |
| covariance | When set to True, creates a table of the variance/covariance matrix. |
| csscp | When set to True, creates a table of the corrected sum of squares and cross-products. |
| descriptiveStats | When set to True, univariate descriptive statistics are generated for the analysis variables. |
| display | Specifies a list of results tables to send to the client for display. |
| excludeNonPosWgt | When set to True, excludes from the analysis observations that have nonpositive weight values. |
| excludePairStats | When set to True, suppresses the display of statistics associated with pairwise deletion. |
| excludeProbs | When set to True, suppresses the computation of the probabilities that are associated with each correlation coefficient. |
| freq | Specifies a numeric variable that contains the frequency of occurrence of each observation. |
| groupByLimit | Specifies the maximum number of levels in a group-by set. When the server determines this number of levels, the server stops and does not return a result. |
| groupbyTable | Specifies an input table that contains the groups to use in a group-by analysis. |
| inputs | Specifies the input variables for the analysis. |
| listwiseDelMiss | When set to True, listwise deletion is applied to observations with missing values. |
| outputTables | Lists the names of results tables to save as CAS tables on the server. |
| pairWithInput | Specifies the numeric variables with which correlations of the INPUT parameter variables are to be computed. |
| pearsonOut | Specifies an output table to contain the requested statistics. |
| rank | When set to True, displays ordered correlation coefficients. |
| sscp | When set to True, creates a table of the sum of squares and cross-products. |
| table | Specifies the input data table for the analysis. |
| topCorrelation | Specifies the number of ordered correlation coefficients displayed. |
| varianceDivisor | Specifies the variance divisor in the calculation of variances and covariances. Options are 'DF' (degrees of freedom), 'N' (number of observations), 'WDF' (sum of weights minus one), or 'WEIGHT' (sum of weights). |
| varInfo | When set to True, creates a table of variable information. |
| weight | Specifies a numeric variable that is used as a weight in the calculation of Pearson weighted product-moment correlation. |
This example uses the 'cars' data set from the 'sashelp' library, which is commonly available in SAS environments. The data contains information about various car models, including their price, engine specifications, and fuel efficiency. This code loads the 'cars' table into your active caslib 'mycas' for use in the correlation examples.
| 1 | DATA mycas.cars; SET sashelp.cars; RUN; |
This example computes the Pearson product-moment correlation coefficients for a selection of numeric variables from the 'cars' data set. It provides a quick overview of the linear relationships between key vehicle attributes.
| 1 | |
| 2 | PROC CAS; |
| 3 | SIMPLE.correlation TABLE={name='cars'} inputs={'MSRP', 'Invoice', 'EngineSize', 'Cylinders', 'Horsepower', 'MPG_City', 'MPG_Highway', 'Weight', 'Wheelbase', 'Length'}; |
| 4 | |
| 5 | RUN; |
| 6 |
This example demonstrates a more comprehensive correlation analysis. It computes the Pearson correlations, includes Cronbach's coefficient alpha to assess reliability, and saves the resulting correlation matrix to a new CAS table named 'corr_results' for further analysis. The `listwiseDelMiss=TRUE` option ensures that only complete cases are used.
| 1 | |
| 2 | PROC CAS; |
| 3 | SIMPLE.correlation TABLE={name='cars'} inputs={'MSRP', 'Invoice', 'EngineSize', 'Cylinders', 'Horsepower', 'MPG_City', 'MPG_Highway', 'Weight', 'Wheelbase', 'Length'} alpha=true listwiseDelMiss=true casOut={name='corr_results', replace=true}; |
| 4 | |
| 5 | RUN; |
| 6 |