问题
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:
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;
来源:https://stackoverflow.com/questions/17434016/sas-create-a-frequency-of-variable-frequencies