Help using Base SAS procedures

Producing a combined correlation matrix using PROC MIANALYZE

Reply
Occasional Contributor
Posts: 10

Producing a combined correlation matrix using PROC MIANALYZE

Hi all,

I cannot seem to figure out the code to create a combined correlation matrix from several imputed datasets.

I have used Proc Corr to output a datafile with the correlation matrices from 5 imputed datasets using the code below. However, I cannot seem to figure out the Proc Mianalyze code to output the combined matrix - the latter code just produces combined means and standard errors. Does anyone know how to combine and output the correlation matrix?

* output stacked dataset with correlation matrices for each imputed dataset;
proc corr data=temp out = outcorr;
var x1 x2 x3 x4 ;
by _imputation_;
run;

*combine results using proc mianalyze;
proc mianalyze data=outcorr ;
modeleffects x1 x2 x3 x4;
run;

Thank you for your time and any help you can offer!
Jon
Occasional Contributor
Posts: 10

Re: Producing a combined correlation matrix using PROC MIANALYZE

A member of SAS technical support provided me with an answer to this query. I am posting the code below in case this helps anyone else...


* Below is a sample program that shows how to get a combined correlation matrix using MIANALYZE ;

data FitMiss;
input Oxygen RunTime RunPulse @@;
x=rannor(412432)*oxygen;
datalines;
44.609 11.37 178 45.313 10.07 185
54.297 8.65 156 59.571 . .
49.874 9.22 . 44.811 11.63 176
. 11.95 176 . 10.85 .
39.442 13.08 174 60.055 8.63 170
50.541 . . 37.388 14.03 186
44.754 11.12 176 47.273 . .
51.855 10.33 166 49.156 8.95 180
40.836 10.95 168 46.672 10.00 .
46.774 10.25 . 50.388 10.08 168
39.407 12.63 174 46.080 11.17 156
45.441 9.63 164 . 8.92 .
45.118 11.08 . 39.203 12.88 168
45.790 10.47 186 50.545 9.93 148
48.673 9.40 186 47.920 11.50 170
47.467 10.50 170
;

proc mi data=FitMiss seed=3237851 noprint out=outmi;
var Oxygen RunTime RunPulse x;
run;

proc corr data=outmi fisher(biasadj=no);
var Oxygen RunTime runpulse x;
by _Imputation_;
ods output FisherPearsonCorr= outz;
run;


data outz;
set outz;
StdZ= 1. / sqrt(NObs-3);
pair=trim(left(var))||trim(left(withvar));
run;
proc sort data=outz;
by pair _imputation_;
run;

proc mianalyze data=outz;
by pair;
ods output ParameterEstimates=parms;
modeleffects ZVal;
stderr StdZ;
run;
data corr_ci;
set parms;
label r='Correlation Coefficient';
r=tanh( Estimate);
run;
proc print data=corr_ci label;
run;
Ask a Question
Discussion stats
  • 1 reply
  • 174 views
  • 0 likes
  • 1 in conversation