我有时间在 SAS Enterprise Guide 中,如下所示:
COL1 | COL2 | COL3 |
---|---|---|
10 | 12 | 44 |
15 | 8 | 2 |
10 | 12 | 44 |
我需要选择重复的行——>选择重复的行,但只选择那些在每列中出现重复的行
COL1 | COL2 | COL3 |
---|---|---|
10 | 12 | 44 |
10 | 12 | 44 |
如何在 SAS Enterprise Guide / PROC SQL 中做到这一点?
如果你想消除只出现一次的观察结果,那么你可以这样做:
proc sort data=have out=want ;
by col1 col2 col3 ;
run;
data want;
set want;
by col1 col2 col3 ;
if not (first.col3 and last.col3) ;
run;
独特的行是他们的唯一行分组,所以他们既是第一行又是最后一行。
如果有很多变量并且您不确定使用 _all_ 变量列表时哪个最后一个会结束,这是一个技巧。只需将任何一个添加到最后并使用它。
proc sort data=have out=want ;
by _all_;
run;
data want;
set want;
by _all_ col2;
if not (first.col2 and last.col2) ;
run;