title 'Within and Between Group SSCP'; data means; input group x1bar x2bar r; list; cards; 1 10 30 .70 2 20 20 .60 3 30 10 .65 data groups; set means; drop x1bar x2bar r; do subj = 1 to 30; x1 = x1bar + 2*normal(125423); x2 = x2bar + 2*normal(125423) + r*(x1-x1bar); output; end; proc plot data=groups; plot x2 * x1 = group; proc corr data=groups nosimple noprob; var x1 x2; title2 'Total Sample Correlations'; proc corr data=groups nosimple noprob; var x1 x2; by group; title2 'Within Sample Correlations'; /*------------------------------------------------------* | Find deviations from group cell means and correlate | | these, producing pooled within-cell correlations. | | In the PROC STANDARD step, use the option M=0 | | and BY GROUP to set each group means to zero. | *------------------------------------------------------*/ proc standard data=groups out=dev m=0; var x1 x2; by group; proc corr data=dev noprob outp=pooled; /* Output data set with correlations*/ var x1 x2; title2 'Pooled Within-Sample Correlations'; proc print data=pooled; proc plot data=dev; plot x2 * x1 = group; *-- Testing whether covariance matrices are similar enough to be pooled using PROC DISCRIM; proc discrim data=groups pool=test slpool=.05 pcorr tcorr short noclassify; class group; var x1 x2;