proc 制表得到 `sumproduct` 结果

proc tabulate get `sumproduct` result

数据看起来像

TM  a  b  c
A   1  2  0.5
B   2  5  0.4

理想的输出是

TM  c
A   0.5
B   0.4
All 3/7 

我在 proc tabulate 中尝试了 pctsum。但它并没有按照我预期的方式工作。

proc tabulate data = dat;
class TM;
var a b c;
table (TM='' all), (c * pctsum<b>='' * f=5.1);
run;

我了解到您希望总计为 C 列的平均值,由 B 列加权。在 table 语句中使用 c * mean 并添加 weight 语句.您将无法将总数显示为分数,但您可以增加格式中的小数位数:

proc tabulate data = dat;
class TM;
var a b c;
table (TM='' all), (c * mean='' * f=5.3);
weight b;
run;

新选项:对于不同变量的不同权重,使用多个var语句并为每个语句添加一个weight=选项:

proc tabulate data = dat;
class TM;
var b / weight=a;
var c / weight=b;
table (TM='' all), (c * mean='' * f=5.3)
                   (b * mean='' * f=5.3);
run;