Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- SAS Procedures
- /
- select variables

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

☑ This topic is **solved**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 10-19-2023 03:29 PM
(135 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

Paige Miller

1 REPLY 1

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

Paige Miller

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

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.