BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
sasphd
Lapis Lazuli | Level 10

Hello, 

in correlation matrix resulting from the output of proc corr , I want to select all variables having correlation more than 0.8. 

have 

        A   B   C

A 0.3 0.6 0.8

B 0.2  0.8  0.9

C 0.1 0.6 0.4

want 

       B   C

A    .      0.8

B    0.8  0.9

 

thanks 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

So, you have the correlation matrix in a SAS data set. I assume that it was created by PROC CORR.

 

data want;
    set corr(where=(_type_='CORR'));
    array x _numeric_;
    do i=1 to dim(x);
        if x(i)<0.8 then x(i)=.;
     end;
run;

 

You can then (if you want) delete rows that are all missings, and delete all columns that are all missing.

 

By the way, it is always helpful if the data you show us could be real and is representative of the actual problem in all relevant ways, even if the data itself if fake. This data violates the conditions of what a correlation matrix should look like. How is the correlation of A with A equal to 0.3? How is the correlation A with C equal to 0.8 and the correlation of C with A equal to 0.1? Perhaps your data set isn't really a correlation matrix? Perhaps it was created via some other method, which would be helpful to know. In fact, I think you should tell us how this matrix was created.

--
Paige Miller

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26

So, you have the correlation matrix in a SAS data set. I assume that it was created by PROC CORR.

 

data want;
    set corr(where=(_type_='CORR'));
    array x _numeric_;
    do i=1 to dim(x);
        if x(i)<0.8 then x(i)=.;
     end;
run;

 

You can then (if you want) delete rows that are all missings, and delete all columns that are all missing.

 

By the way, it is always helpful if the data you show us could be real and is representative of the actual problem in all relevant ways, even if the data itself if fake. This data violates the conditions of what a correlation matrix should look like. How is the correlation of A with A equal to 0.3? How is the correlation A with C equal to 0.8 and the correlation of C with A equal to 0.1? Perhaps your data set isn't really a correlation matrix? Perhaps it was created via some other method, which would be helpful to know. In fact, I think you should tell us how this matrix was created.

--
Paige Miller

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 480 views
  • 1 like
  • 2 in conversation