BookmarkSubscribeRSS Feed
marzieh
Calcite | Level 5

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

3 REPLIES 3
data_null__
Jade | Level 19

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;

Linlin
Lapis Lazuli | Level 10

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

Ksharp
Super User

You need variable cluster method.

proc varclus

Ksharp

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

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.

Discussion stats
  • 3 replies
  • 1222 views
  • 0 likes
  • 4 in conversation