Hi
I have a data set like
A B C D E
1 12 3.2 ....
1.5 10 4
1.3 11 5.6
.
.
.
I want to extract name of correlated variables from it
for example I want a result like this:
A B
C D
E
which means A&B are correlated, C&D are correlated and E in independent
I used proc corr to have correlation matrix but I don't know how can I extract name of correlatd variables from it.
Can anybody help me in this issue?
Thanks a lot
This works but It seems like I remember an easier way, oh well. :smileyplain:
ods output PearsonCorr= PearsonCorr;
proc corr data=sashelp.heart;
run;
ods output close;
proc transpose out=probs;
by variable notsorted;
var PAgeCHDdiag--PCholesterol;
run;
data probs(keep=Variable With);
set probs;
by variable notsorted;
if first.variable then do;
i + 1;
j = 0;
end;
j + 1;
if i ge j then delete; *Upper;
if col1 gt .05 then delete; *Cutoff;
length With $32;
with = substr(_name_,2);
run;
options byline=1;
proc print;
by variable notsorted;
id variable;
run;
data have;
infile cards missover;
input A B C D E;
cards;
1 12 3.2 . .
1.5 10 4 . 8
1.3 11 5.6 7 9
;
run;
data ab (rename=(a=var1 b=var2));
set have(keep=a b);
i=_n_;
group=1;
data cd (rename=(c=var1 d=var2));
set have(keep=c d);
i=_n_;
group=2;
data e (rename=(e=var1));
set have(keep=e);
i=_n_;
group=3;
data want (keep=var:);
set ab cd e;
by i group;
run;
proc print;
run;
Linlin
You need variable cluster method.
proc varclus
Ksharp
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.