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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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