SAS create a frequency of variable frequencies

萝らか妹 提交于 2021-01-29 09:07:57

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!