create new tag
, view all tags, tagging instructions

  • Corr.sas: Macro for Pearson and Spearman correlations

MacroHeaderForm edit

Macro Name


Description The corr macro produces Pearson and/or Spearman correlations with 95% confidence intervals and P-Values.

Variable lists can be crossed or paired.The second variable list can be omitted to generate all non-redundant pairs of the first list. Output can be sorted by variable name or according to the list order or by absolute Pearson or Spearman value. Missing values can be deleted on a listwise or pairwise basis.

Relevant Links:

Checklist for Corr Suggestions of what to look for in the output and how to deal with some issues that you may find.
Macro Parameters DSName = data set name
IVar = 1st variable list (cannot be empty)
JVar = 2nd variable list (can be empty)
Pairs = X|P If X, then all IVar variables paired with all JVar variables. If P, then the 1st IVar variable is paired with the 1st JVar variable, etc. This option requires the two lists to have the same number of variables. This option is ignored if JVar list is empty. Default is X.
Missing = L|P If L, then listwise deletion of missing values, otherwise pairwise deletion of missing values. Default is P.
ByVars = any By variables
Print = Y|N. Default is Y.
Out = output data set
Label = Y|N to label printed output. Default is Y.
Sort = A|O|P|S. If A, then output is sorted by IVar variable name, then JVar name within IVar. If O, then the original order in IVar with each IVar paired with each JVar. If P, output is sorted by descending absolute Pearson correlation. If S, output is sorted by descending absolute Spearman correlation. Default is O.

Programmer AlanBostrom
Revision March 20, 2009

Example(s) %corr(DSName=sample,IVar=Age Weight Height, JVar=DeltaWeight,ByVars=Treatment,Print=Y)

Three Pearson and Spearman correlations with 95% confidence limits and P-values will be produced for each level of Treatment. Missing values will be deleted on a pairwise basis and the order of the correlations will be the order given in the JVar list.
Special Features

Called Macros The macros called by corr are CheckVar, Varlist, and Words.;
Notes When directing output to a SAS file, the command ods listing; must be given before printing the file.
See Also

Topic attachments
I Attachment Action Size Date Who Comment
elsesas Corr.sas manage 10.8 K 13 Mar 2009 - 15:16 AlanBostrom Macro for Pearson and Spearman correlations
Topic revision: r8 - 17 Jul 2009 - 13:48:13 - CTSpediaAdmin

Copyright & by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding CTSPedia? Send feedback