data a;
input ID$ Num type;
cards;
001 1 1
001 2 1
001 3 1
002 2 1
002 1 0
002 2 1
003 1 1
003 4 1
;
data b;
do _n_=1 by 1 until(last.id);
set a;
by id;
if type=0 then del_flag=1;
end;
do _n_=1 to _n_;
set a;
output;
end;
run;
proc print data=b;
run;
结果为:
obs ID NUM TYPE del_flag
1 001 1 1 .
2 001 2 1 .
3 001 3 1 .
4 002 2 1 1
5 002 1 0 1
6 002 2 1 1
7 003 1 1 .
8 003 4 1 .
为什么ID为002的所有del_flag都为1呢?我的理解是只有TYPE为0 的那条记录为1 ???
整个PDV流程是怎样的呢?