Examining Correlation in Data: Fall 1992 Use PROC CORR SAS Primer Examining Correlation in Data: Use PROC CORR PROC CORR calculates correlation coefficients between variables. The procedure by default calculates Pearson product-moment correlation and significance probabilities. This is all that will be covered here. Check with the SAS manuals at your computing site for information on the options used with PROC CORR to calculate nonparametric statistics measuring association and partial correlation. The following statements are used to invoke the CORR procedure PROC CORR [DATA=setname ]; Invokes PROC CORR and optionally specifies the name of the data set to be processed. [VAR variables ]; Lists the variables to be correlated. [WITH variables] ; Specifies specific combinations of variables to be correlated. Variables in the VAR statement define the columns of the correlation table results and variables in the WITH statement define the rows of the correlation table results. If WITH is omitted, VAR defines both rows and columns. [BY variables ]; Processes the data set in groups of observations defined by the variables in the BY statement. For example, the following SAS code: PROC CORR DATA=SET1; VAR A B; WITH X Y Z; produces correlation coefficients for the following pairs of variables: A and X, A and Y, A and Z, B and X, B and Y, B and Z. Example: Calculating Pairwise correlation Calculate the Pearson Product-Moment Correlation for all pairwise combinations of yield, ph and temp from the chemical reaction data set from the example on "Reading Values into a Data Set". SAS SOLUTION: options pagesize=50; data react; input yield ph temp @@; psq=ph**2; tsq=temp**2; pt=ph*temp; cards; 90 5 60 100 5 80 95 5 100 105 5.5 80 100 6 60 130 6 80 125 6 100 140 6.5 80 135 7 60 142 7 80 126 7 100 ; proc corr; var yield ph temp; run; SAS OUTPUT: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Correlation Analysis 3 'VAR' Variables: YIELD PH TEMP Simple Statistics Variable N Mean Std Dev Sum Minimum Maximum YIELD 11 117.0909 19.3052 1288 90.0000 142.0000 PH 11 6.0000 0.8062 66.0000 5.0000 7.0000 TEMP 11 80.0000 15.4919 880.0000 60.0000 100.0000 Pearson Correlation Coefficients / Prob > |R| under Ho: Rho=0 / N = 11 YIELD PH TEMP YIELD 1.00000 0.87058 0.14043 0.0 0.0005 0.6805 PH 0.87058 1.00000 0.00000 0.0005 0.0 1.0000 TEMP 0.14043 0.00000 1.00000 0.6805 1.0000 0.0 The table in the output show the correlation for all pairs of the variables. For example, the correlation between PH and YIELD is .87058 (p=.0005).