我有一个跨 5 个变量的数据集。第 5 个是标识符变量。最后,我有第 6 个变量,它取决于标识符变量。
标识符变量可以出现在多个位置。对于标识符变量的给定值,因变量永远不会改变。
我有如下代码:
proc sql;
select
...
, count(distinct identifier) as n_ids
from
group by
它选择每组 4 个自变量的唯一标识符的数量。我希望在此基础上加上第 6 个变量的总和,如下所示:
sum(case when distinct identifier then dependent_var else 0 end)
这显然不起作用(并且有充分的理由)。在 sql 步骤中找到这个总和的任何干净方法?