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

Showing results for

Options

- 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** and **locked**.
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 08-22-2018 11:13 PM
(1400 views)

Hi everyone,

I have a matrix created based on raw data. I want to use this matrix as input for cluster analysis. Can anyone help me to define that matrix as input? Here is the code I use. I tried that code but it did not work. I don't know what I'm missing. I also attached raw data I used.

Thanks

data tr;

infile 'C:\coll_gen\N100\GROUP10\COMP40\PHI25\gbt\RESULTS-SIG1.OUT';

input CAND_1$ CAND_2$ ID_1 ID_2 THETA_1 THETA_2 MATCHES RT_PROB FLAG ;

run;

proc iml;

use tr nobs nobs;

read all var{CAND_1 CAND_2 RT_PROB};

close;

levels=unique(CAND_1||CAND_2);

matrix1=j(ncol(levels),ncol(levels),.);

mattrib matrix1 r=((levels)) c=((levels)) label='' ;

row=(CAND_1);

col=(CAND_2);

do i=1 to nobs;

r=row[i];c=col[i];p=RT_PROB[i];

matrix1[r,c]=p;

end;

print matrix1;

quit;

ods graphics on;

proc cluster data=matrix1 method=ward ccc pseudo out=tree;

var RT_PROB;

id CAND_1;

run;

ods graphics off;

proc tree data=matrix1 out=New nclusters=5 noprint ;

height _rsq_;

copy RT_PROB ;

run;

1 ACCEPTED SOLUTION

Accepted Solutions

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

You can export row and column names at the same time as the matrix. For example:

```
create matrix1 from matrix1 [rowname=levels colname=levels];
append from matrix1 [rowname=levels ];
```

3 REPLIES 3

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

All the matrices in IML are destroyed when you exit the procedure with 'quit'. In order to do what you want, you will need to add the IML statements:

```
create matrix1 from matrix1;
append from matrix1;
```

to export the contents of matrix1 to a SAS data set. There are other problems as matrix1 will be very sparse, mostly with missing values, and you will not be able to run a cluster analysis on it.

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

Hi lanWakeling,

Thanks for your response,

I added the statements you mentioned. Now I have the matrix but it does not have the candidates id numbers in rows and columns. I attached the output.

Thanks

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

You can export row and column names at the same time as the matrix. For example:

```
create matrix1 from matrix1 [rowname=levels colname=levels];
append from matrix1 [rowname=levels ];
```

Are you ready for the spotlight? We're accepting content ideas for **SAS Innovate 2025** to be held May 6-9 in Orlando, FL. The call is **open **until September 25. Read more here about **why** you should contribute and **what is in it** for you!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.