0
votes

I would like to create a table that lists the frequency of each variables frequencies. For example, a data set with 100 rows and 4 variables: ID, A, B, and C.

What I'm looking for would be like this:

Freqs|   ID    A    B    C
----------------------------
1    |  100   20   15   10
2    |    0   40   35    0
3    |    0    0    5   30

Since there are 100 unique IDs, there will be a frequency of 100 frequencies of 1 from the original data.

edit for clarification: If you did a proc freq on the original data, you would get a frequency of 1 for every ID. Then if you did a proc freq on the count, you would have a frequency of 100 for counts of 1. I'm looking for that for every variable in a data set.

1
Not sure what you mean using 'frequencies' in multiple places there. Sounds like some sort of proc freq or proc tabulate. What does 'freqs' mean? Is Freqs=1 the number of unique values that only appear once, Freqs=2 the number of unique values that appear twice, etc.?Joe
If you did a proc freq on the original data, you would get a frequency of 1 for every ID. Then if you did a proc freq on the count, you would have a frequency of 100 for counts of 1. I'm looking for that for every variable in a data set.user2516799
Good clarification. I'd edit that into the question, or even make that the question - it is a much clearer question than your original :)Joe

1 Answers

0
votes

This should do what you want. You probably want to process the preds table since it contains "Table" in each table name, but this is a pretty simple way to do this.

ods output onewayfreqs=preds;
proc freq data=sashelp.class;
tables _all_;
run;
ods output close;

proc tabulate data=preds;
class table frequency;
tables frequency,table;
run;