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
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.
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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.