我在SAS企业指南中有如下表格:
- ID-数字
- COL1-数字
ID | COL1 |
---|---|
123 | 2 |
123 | 0 |
123 | 0 |
444 | 1 |
444 | 0 |
778 | 0 |
您的逻辑相当于为每个ID获取列的最大值。
proc sql;
create table want as
select ID, max(col1) as Target
from have
group by ID;
quit;
您可以在组上使用DOW循环,计算重复的OR结果。
示例:
data want;
do until (last.id);
set have;
by id;
if not target then
target = target or col1;
end;
run;