* V9.1的时候
proc sort data=abs out=_b1 dupout=_b2 nodupkey;
by ksdm rq;
run;
[/code:2iomnahs]作者: shiyiming 时间: 2012-12-22 10:17 标题: Re: 请教:利用nodupkey可以去重复数据,但有没有简单办法把重复数据挑出来 Good idea! This could be a little more concise:
proc sql;
create table one_a as
select *, monotonic() as id
from abs
order by ksdm,rq;
create table two_a as
select *
from one_a
group by ksdm,rq
having max(id) ne min(id);
create table one as
select *
from abs
order by
ksdm,rq;
create table two as
select *, monotonic() as id
from one;
create table three as
select *
from two
group by ksdm,rq
having max(id)^=min(id);
alter table three drop id;
quit;
[/code:2pm7kenj][/quote:2pm7kenj]作者: shiyiming 时间: 2013-1-6 23:25 标题: Re: 请教:利用nodupkey可以去重复数据,但有没有简单办法把重复数据挑出来 [quote="faithd":rkoxlgzz]版主的第一种方法是求出相同数据的第一条和最后一条数据,如果要输出所有的重复值,需要修改判断语句如下:
将语句
if first.rq^=last.rq then output two;
修改为:
if first.rq^=last.rq or (last.rq =0 and first.rq=0) then output two;[/quote:rkoxlgzz]