Depending on the PROC CORR syntax, a PearsonCorr table is generated showing the following statistics:
If changes are desired to any of the tables generated by PROC CORR or other procedures, the ODS TRACE ON statement can be used to determine which table template is being used. The table template can be edited with PROC TEMPLATE to adjust the results in the output destination(s). The Full Code tab shows how to change the Matrix2 column (p-value) to have the PVALUE8.6 format, and display the values in red. The style (color) change takes effect in all non-Listing destinations.
The ODS TRACE ON information statement used in conjunction with this code is shown below:
ods trace on;
proc corr data=sashelp.cars;
var cylinders mpg_highway mpg_city horsepower length;
run;
The ODS TRACE ON statement generates the following information in the SAS log:
Output Added:
-------------
Name: PearsonCorr
Label: Pearson Correlations
Template: base.corr.StackedMatrix
Path: Corr.PearsonCorr
The template name BASE.CORR.StackedMatrix is used in the EDIT statement in PROC TEMPLATE to generate the desired changes.
Full Code
The sample code below edits the Matrix2 column (p-value) to use the PVALUE8.6 format, and change the text of the p-value statistic to red.
/* Add the WORK library to the ODS PATH */
ods path (prepend) work.template(update);
/* The Matrix column is the correlation,
Matrix2 is the p-value,
Matrix3 is the number of observations contributing
*/
proc template;
edit base.corr.stackedmatrix;
column (RowName RowLabel) (Matrix) * (Matrix2) * (Matrix3) * (Matrix4);
edit matrix2 ;
format=pvalue8.6;
style={foreground=red};
end;
end;
run;
title;
footnote;
/*Remove "The CORR Procedure" from the output */
ods nopproctitle;
ods trace on;
ods escapechar="^";
options orientation=portrait nodate nonumber;
ods rtf file="file.rtf" startpage=no;
/* Exclude all other libraries from the ODS PATH. */
/* This is used for demonstration purposes to show */
/* the default PROC CORR Pearsoncorr table's output. */
ods path sashelp.tmplmst;
ods rtf text="^S={just=c outputwidth=100% font_size=13pt font_weight=bold}Default output";
ods select pearsoncorr;
proc corr data=sashelp.cars ;
var cylinders mpg_highway mpg_city horsepower length;
run;
ods path (prepend) work.template(update);
ods rtf text="^S={just=c outputwidth=100% font_size=13pt font_weight=bold}Pvalues are now red and have more decimal places";
ods select pearsoncorr;
proc corr data=sashelp.cars ;
var cylinders mpg_highway mpg_city horsepower length;
run;
ods _all_ close;
/* Turn off ODS TRACE */
ods trace off;
/* Delete the edited BASE.CORR.StackedMatrix table template */
proc template;
delete base.corr.stackedmatrix;
run;
Output
Click here to view the RTF output.