SAS创建可变频率 [英] SAS create a frequency of variable frequencies

查看:64
本文介绍了SAS创建可变频率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个表,列出每个变量频率的频率.例如,一个具有100行和4个变量的数据集:ID,A,B和C.

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

由于有100个唯一ID,因此原始数据的频率为100,频率为1.

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

修改说明:如果您对原始数据执行了proc freq,则每个ID的频率均为1.然后,如果对计数进行proc freq,则计数1的频率为100.我正在寻找数据集中每个变量的频率.

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.

推荐答案

这应该做您想要的.您可能要处理 preds 表,因为它在每个表名中都包含表",但这是一种非常简单的方法.

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;

这篇关于SAS创建可变频率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆