简体   繁体   English

SAS创建可变频率

[英]SAS create a frequency of variable frequencies

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. 例如,一个具有100行和4个变量的数据集:ID,A,B和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. 由于有100个唯一ID,因此原始数据的频率为100,频率为1。

edit for clarification: If you did a proc freq on the original data, you would get a frequency of 1 for every ID. 编辑以澄清问题:如果对原始数据进行了proc freq,则每个ID的频率为1。 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. 然后,如果对计数进行了proc freq,则计数1的频率为100。我正在寻找数据集中每个变量的频率。

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. 您可能要处理preds表,因为它在每个表名中都包含“ Table”,但这是一种非常简单的方法。

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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM