simple

correlation

Description

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.

simple.correlation <result=results> <status=rc> / alpha=TRUE | FALSE, attributes={{...}, {...}}, casOut={...}, covariance=TRUE | FALSE, csscp=TRUE | FALSE, descriptiveStats=TRUE | FALSE, display={...}, excludeNonPosWgt=TRUE | FALSE, excludePairStats=TRUE | FALSE, excludeProbs=TRUE | FALSE, freq="variable-name", groupByLimit=64-bit-integer, groupbyTable={...}, inputs={{...}, {...}}, listwiseDelMiss=TRUE | FALSE, outputTables={...}, pairWithInput={{...}, {...}}, pearsonOut={...}, rank=TRUE | FALSE, sscp=TRUE | FALSE, table={...}, topCorrelation=integer, varianceDivisor="DF" | "N" | "WDF" | "WEIGHT", varInfo=TRUE | FALSE, weight="variable-name";
Settings
ParameterDescription
alphaWhen set to True, computes Cronbach's coefficient alpha.
attributesSpecifies the variable attributes.
casOutSpecifies the settings for an output table.
covarianceWhen set to True, creates a table of the variance/covariance matrix.
csscpWhen set to True, creates a table of the corrected sum of squares and cross-products.
descriptiveStatsWhen set to True, univariate descriptive statistics are generated for the analysis variables.
displaySpecifies a list of results tables to send to the client for display.
excludeNonPosWgtWhen set to True, excludes from the analysis observations that have nonpositive weight values.
excludePairStatsWhen set to True, suppresses the display of statistics associated with pairwise deletion.
excludeProbsWhen set to True, suppresses the computation of the probabilities that are associated with each correlation coefficient.
freqSpecifies a numeric variable that contains the frequency of occurrence of each observation.
groupByLimitSpecifies 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.
groupbyTableSpecifies an input table that contains the groups to use in a group-by analysis.
inputsSpecifies the input variables for the analysis.
listwiseDelMissWhen set to True, listwise deletion is applied to observations with missing values.
outputTablesLists the names of results tables to save as CAS tables on the server.
pairWithInputSpecifies the numeric variables with which correlations of the INPUT parameter variables are to be computed.
pearsonOutSpecifies an output table to contain the requested statistics.
rankWhen set to True, displays ordered correlation coefficients.
sscpWhen set to True, creates a table of the sum of squares and cross-products.
tableSpecifies the input data table for the analysis.
topCorrelationSpecifies the number of ordered correlation coefficients displayed.
varianceDivisorSpecifies 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).
varInfoWhen set to True, creates a table of variable information.
weightSpecifies a numeric variable that is used as a weight in the calculation of Pearson weighted product-moment correlation.
Data Preparation View data prep sheet
Create the 'cars' Data Set

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.

Copied!
1DATA mycas.cars; SET sashelp.cars; RUN;

Examples

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.

SAS® / CAS Code Code awaiting community validation
Copied!
1 
2PROC CAS;
3SIMPLE.correlation TABLE={name='cars'} inputs={'MSRP', 'Invoice', 'EngineSize', 'Cylinders', 'Horsepower', 'MPG_City', 'MPG_Highway', 'Weight', 'Wheelbase', 'Length'};
4 
5RUN;
6 
Result :
The action generates a correlation matrix for the specified numeric variables, showing the linear relationship between each pair. It also provides descriptive statistics for each variable by default.

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.

SAS® / CAS Code Code awaiting community validation
Copied!
1 
2PROC CAS;
3SIMPLE.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 
5RUN;
6 
Result :
The output includes descriptive statistics, Cronbach's alpha, and the Pearson correlation matrix. Additionally, a new in-memory table named 'corr_results' is created in the active caslib, containing the detailed correlation statistics for subsequent use.

FAQ

What is the primary function of the simple.correlation action?
How can I compute Cronbach's coefficient alpha using this action?
What options are available for handling missing values?
How can I specify the divisor for variance and covariance calculations?
Can I get other statistics besides the correlation matrix?
How can I save the correlation results to a CAS output table?
Is it possible to compute correlations for specific pairs of variables instead of all possible pairs?