Written and maintained by CASRAI Editorial Board
Published
On this page
PROC CORR is the SAS procedure that computes correlation coefficients between numeric variables. Run proc corr data=mydata; var x y z; run; and SAS prints simple descriptive statistics plus a table of Pearson product-moment correlations with p-values and, for each pair, the number of observations used. Adding the SPEARMAN, KENDALL or HOEFFDING option requests rank-based or dependence measures instead, and each of those changes whether Pearson is still printed. The details below follow the Base SAS 9.4 Procedures Guide: Statistical Procedures, Fifth Edition.
What PROC CORR is used for in research
PROC CORR belongs to the SAS/STAT statistical procedures and measures association between variables. The documentation describes four main measures that one call can produce: the Pearson product-moment correlation, the Spearman rank-order correlation, Kendall’s tau-b and Hoeffding’s measure of dependence, D. Beyond those, the same statement can request polychoric and polyserial correlations, Fisher’s z confidence limits, Cronbach’s coefficient alpha, covariance and sums-of-squares matrices, partial correlations and scatter plots.
In a research workflow the procedure typically sits early in an analysis: it shows which variables move together, how much data each pairwise result rests on, and whether a rank-based coefficient tells a different story from Pearson. It is a descriptive and screening step. A companion procedure for data checks is PROC UNIVARIATE in SAS, and when you move from association to a model, modelling in SAS and PROC MIXED are the usual next steps.
Rank-based alternatives are worth knowing before you choose an option. The CASRAI guide to the Kendall tau correlation coefficient explains what tau-b measures, and the PROC CORR section below shows how to request it.
How to install or access PROC CORR
PROC CORR is part of the SAS statistical procedures documented in the Base SAS 9.4 Procedures Guide: Statistical Procedures, so it is available wherever your SAS installation includes them. If your institution does not provide SAS, SAS publishes SAS OnDemand for Academics, described on the SAS website as a free, cloud-based learning environment for statistical analysis and programming. Its SAS Studio option is listed for use on Windows, Mac or Linux without installing or managing software locally, and the SAS Cloud lets each user upload up to 5GB of data.
Start from the official SAS OnDemand for Academics page linked in the Sources list; the Enterprise Guide edition requires registering a course, while the Studio edition is described as not gated.
How to run PROC CORR step by step
- Put the data in a SAS data set. The
DATA=option names the data set to analyse. If you omit it, the procedure uses the most recently created SAS data set, which is a common source of silent mistakes in long programs, so name it every time. - Write the PROC CORR statement. The syntax is
PROC CORR ‹options›;. Companion statements are BY, FREQ, ID, PARTIAL, VAR, WEIGHT and WITH. - List the variables with a VAR statement.
VAR variables;names the variables to correlate. If you leave it out, PROC CORR uses all numeric variables not listed in other statements. - Choose the coefficients. Add
PEARSON,SPEARMAN,KENDALLorHOEFFDINGas needed (see the Pearson default trap below). - Decide how to treat missing values. By default PROC CORR uses all nonmissing pairs of variables. Add
NOMISSto exclude every observation that has a missing value on any analysis variable. - Run the step and read the tables. End with
run;.
The documentation’s own four-measure example uses the Fitness data set of 31 participants:
ods graphics on;title 'Measures of Association for a Physical Fitness Study';proc corr data=Fitness pearson spearman kendall hoeffding plots=matrix(histogram); var Weight Oxygen RunTime;run;
PROC CORR in SAS with a WITH statement
The WITH statement computes correlations between the VAR variables and a second list. The documentation’s illustration is proc corr; var x1 x2; with y1 y2 y3; run;, which produces a rectangular matrix of the VAR variables against the WITH variables rather than a square matrix. The ALPHA option is invalid when a WITH statement is specified.
SAS PROC CORR by group, with weights and with partial correlations
A BY statement gives separate analyses for each group, and the input data set must be sorted by the BY variables unless you use the NOTSORTED or DESCENDING option, create an index with PROC DATASETS, or sort first with PROC SORT. A FREQ statement treats each observation as n observations, truncating a non-integer n and excluding observations whose value is below 1 or missing. A WEIGHT statement requests a weighted Pearson product-moment correlation. A PARTIAL statement lists the variables to adjust for; only the Pearson partial correlation, the Spearman partial rank-order correlation and Kendall’s partial tau-b can be computed, and observations with missing values are then excluded.
Saving results with OUTP= and the other output options
OUTP= (also written OUT=) creates a data set of Pearson statistics that also includes means, standard deviations and the number of observations, with _TYPE_ equal to ‘CORR’. OUTS=, OUTK= and OUTH= do the same for Spearman, Kendall and Hoeffding, and specifying them also displays those statistics. NOPRINT suppresses all displayed output, including ODS Graphics, so use it when you want only the data set.
How to read the PROC CORR output
With the four-measure example, the Simple Statistics table lists N, mean, standard deviation, median, minimum and maximum for each variable. When nonparametric measures are requested the median replaces the sum. The N in that table is per variable, so Weight shows 31 while Oxygen and RunTime show 29.
The Pearson table then prints, for each pair, the coefficient, the p-value under H0: Rho=0 and the number of observations. In the documentation’s output the Oxygen and RunTime pair has r = -0.86843 with p below .0001 on 28 observations, which the documentation describes as a strong negative linear relationship: as RunTime increases, Oxygen decreases. The Weight and Oxygen pair has r = -0.15358 (p = 0.4264, N = 29).
Notice that the pair counts differ (31 on the diagonal for Weight, 29 for most pairs, 28 for Oxygen with RunTime). The documentation states that when there are missing data the number of observations used for each correlation can vary. This is the default pairwise behaviour; with NOMISS every correlation would use the same complete cases.
Comparing the coefficient families on the same pair is the quickest check that Pearson is not driven by outliers or non-linearity. For Oxygen and RunTime the documentation’s output gives Pearson -0.86843, Spearman -0.80131, Kendall tau-b -0.62434 and a Hoeffding D of 0.23449, each with p below .0001 on 28 observations.
For Hoeffding’s D the documentation notes that, without ties, values vary between -0.5 and 1 with 1 indicating complete dependence, and that ties can give a smaller value. Its Weight diagonal is 0.97690 because Weight contains ties. D detects more general departures from independence than the other three measures, so a large D with a small Pearson r is a signal to plot the data.
The Pearson default trap
Pearson correlations are produced by default only when you do not specify HOEFFDING, KENDALL, SPEARMAN, POLYCHORIC, POLYSERIAL, OUTH=, OUTK= or OUTS=. As soon as you request one of those, you must also specify PEARSON (or ALPHA, COV, CSSCP, SSCP or OUT=) to get Pearson. Scatter plots and scatter plot matrices, by contrast, bring Pearson along automatically. The data table below lists the restrictions and output data set option for each coefficient.
PROC CORR plots in SAS
ODS Graphics must be enabled before plots can be requested. PLOTS=MATRIX displays a scatter plot matrix (add (HISTOGRAM) for histograms on the diagonal) and PLOTS=SCATTER displays scatter plots for pairs of variables, by default with prediction ellipses and an inset of the observation count and correlation. The global option MAXPOINTS= suppresses plots that need more than n points, with a default of 5000, and NVAR= and NWITH= default to 5 variables.
Troubleshooting PROC CORR
- Pearson is missing from the output. You specified SPEARMAN, KENDALL, HOEFFDING or another listed option without PEARSON. Add
PEARSON. - SPEARMAN, KENDALL or HOEFFDING is ignored or invalid. A WEIGHT statement makes all three invalid. HOEFFDING is also invalid with PARTIAL, and KENDALL with PARTIAL gives no probability values for partial tau-b.
- ALPHA does nothing useful with WITH. ALPHA is invalid when a WITH statement is specified.
- Different N values for different pairs. This is pairwise handling of missing values. Use
NOMISSif you need the same observations in every coefficient; the documentation adds that NOMISS is also computationally more efficient. - No plots appear. Check that ODS Graphics is on, that
NOPRINTis not suppressing output, and that the number of points does not exceed the MAXPOINTS default of 5000. - BY-group errors. Sort the data by the BY variables first, or use NOTSORTED when groups are contiguous but not in sorted order. See also PROC CONTENTS in SAS for checking variable names and types, and PROC COMPARE in SAS for confirming that two versions of a data set agree before you re-run an analysis.
- Wrong data set analysed. Without
DATA=, the most recently created data set is used.
Free alternatives to PROC CORR
Other tools compute the same coefficients. The functions below are documented by their own projects; check that their defaults match the SAS options you are replacing before comparing results.
| Tool | Function | What the documentation states |
|---|---|---|
| R (stats package) | cor.test() |
Tests association between paired samples using Pearson’s product moment correlation, Kendall’s tau or Spearman’s rho, selected with method. For Pearson, with at least 4 complete pairs, an asymptotic confidence interval based on Fisher’s Z transform is given. |
| Python (SciPy) | scipy.stats.pearsonr |
Returns the Pearson correlation coefficient and a p-value for testing non-correlation, and the result object has a confidence_interval method. |
Both cover the Pearson workflow that PROC CORR provides by default. SAS adds in a single procedure the Hoeffding, polychoric, polyserial and Cronbach’s alpha options listed in its statement summary.
Sources
- SAS Institute: PROC CORR Statement, Base SAS 9.4 Procedures Guide: Statistical Procedures, Fifth Edition
- SAS Institute: Example 2.1 Computing Four Measures of Association, The CORR Procedure
- SAS Institute: WITH Statement, The CORR Procedure
- SAS Institute: BY Statement, The CORR Procedure
- SAS Institute: PARTIAL Statement, The CORR Procedure
- SAS Institute: WEIGHT Statement, The CORR Procedure
- SAS Institute: SAS OnDemand for Academics
- R Core Team: cor.test, Test for Association/Correlation Between Paired Samples
- SciPy documentation: scipy.stats.pearsonr
Data: PROC CORR coefficient options: statistic, restrictions and output data set option
Compares the correlation coefficients requested on the SAS PROC CORR statement (Pearson, Spearman, Kendall tau-b, Hoeffding D, polychoric, polyserial): what each measures, the restrictions stated in the Base SAS 9.4 Procedures Guide, and the output data set option that stores it.
Period covered: SAS 9.4 documentation.
| PROC CORR option | Statistic requested | Restriction stated in the documentation | Output data set option |
|---|---|---|---|
| PEARSON | Pearson product-moment correlation, range -1 to 1 | With a WEIGHT statement the procedure computes a weighted Pearson correlation; produced by default only if none of HOEFFDING, KENDALL, SPEARMAN, POLYCHORIC, POLYSERIAL, OUTH=, OUTK=, OUTS= is specified | OUTP= (or OUT=) |
| SPEARMAN | Spearman rank-order correlation, range -1 to 1 | Invalid with a WEIGHT statement | OUTS= |
| KENDALL | Kendall's tau-b, range -1 to 1 | Invalid with a WEIGHT statement; probability values for Kendall's partial tau-b are not available with PARTIAL | OUTK= |
| HOEFFDING | Hoeffding's D, scaled 30 times the usual definition, range -0.5 to 1 | Invalid with a WEIGHT or PARTIAL statement | OUTH= |
| POLYCHORIC | Polychoric correlation (tetrachoric for two binary variables) | Not applicable with a WEIGHT statement | OUTPLC= |
| POLYSERIAL | Polyserial correlation | Not applicable with a WEIGHT statement | OUTPLS= |
Sources
- PROC CORR Statement, Base SAS 9.4 Procedures Guide: Statistical Procedures, Fifth Edition (accessed 2026-11-17)
- WEIGHT Statement, The CORR Procedure (accessed 2026-11-17)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







