## How to take the Frequency of an array

Solved
Occasional Contributor
Posts: 9

# How to take the Frequency of an array

How would I be able to take the frequencies in matrix. For the data I am using I have colums A, B, C, D, E., however, they do not represent different variables, so I do not want to know the frequency of each unique entry per column, but rather, the frequency of each unique entry for the matrix as a whole.

Attatched is the matix.

Best,

Accepted Solutions
Solution
‎09-06-2016 03:51 PM
Super User
Posts: 10,761

## Re: How to take the Frequency of an array

```Yes. It is IML thing.

data have;
input a b c d e;
cards;
1 2 3 6 2
3 4 7 1 .
2 . . 3 6
;
run;
proc iml;
use have;
read all var{a b c d e} into x;
close;

call tabulate(level,freq,x);

print (level`)[l='level'] (freq`)[l='freq'];
quit;

```

All Replies
Super User
Posts: 13,498

## Re: How to take the Frequency of an array

And the output should look like what for that example data?

It isn't clear if you are looking for an overall frequency from the entire dataset or per row only.

Also are those the only values that will ever appear among the variables or do you have the possibility of practically unlimited actual values for A B C D and E?

Since you are using the word "matrix" this might be better as a SAS/IML question.

Occasional Contributor
Posts: 9

## Re: How to take the Frequency of an array

I want to take the frequency if the whole dataset and I do not want the output to give me the out put based on A B C D E. They mean nothing for my data.

Solution
‎09-06-2016 03:51 PM
Super User
Posts: 10,761

## Re: How to take the Frequency of an array

```Yes. It is IML thing.

data have;
input a b c d e;
cards;
1 2 3 6 2
3 4 7 1 .
2 . . 3 6
;
run;
proc iml;
use have;
read all var{a b c d e} into x;
close;

call tabulate(level,freq,x);

print (level`)[l='level'] (freq`)[l='freq'];
quit;

```
Occasional Contributor
Posts: 9

## Re: How to take the Frequency of an array

Thanks for your help! It worked!

☑ This topic is solved.