data temp(drop=flag:);
do _n_=1 by 1 until(last.no);
set temp;
by no;
if sigh=1 then flag1=1;
else flag2=1;
end;
if flag1 and flag2 then flag=1;
do _n_=1 to _n_;
set temp;
by no;
if flag=1 then output;
end;
run;
[/code:1m3ecbdd]作者: shiyiming 时间: 2009-10-23 14:51 标题: Re: 急等答案,关于数据集的修改! 那原来数据集中的其他变量还会保留吗?我需要把其他变量保留下来作者: shiyiming 时间: 2009-10-23 15:00 标题: Re: 急等答案,关于数据集的修改! 会保留啊,你运行个程序看看就知道了,那里只是drop了新加的那个参数。作者: shiyiming 时间: 2009-10-23 15:11 标题: Re: 急等答案,关于数据集的修改! 我试试,谢谢!作者: shiyiming 时间: 2009-10-26 21:00 标题: Re: 急等答案,关于数据集的修改! [code:39few8io]data a;
input no $ singn;
datalines;
s1 1
s1 1
s2 1
s2 2
s3 1
s3 1
s4 2
s4 2
;
run;
proc sql;
drop tabale out;
create table bc as
select c.no,c.singn,contno,contsn
from (select no,count(no) as contno from a group by no) b,
(select no,singn,count(no and singn) as contsn from a group by no,singn) c
where b.no=c.no
having contno>contsn;
insert into bc
select c.no,c.singn,contno,contsn
from (select no,count(no) as contno from a group by no) b,
(select no,singn,count(no and singn) as contsn from a group by no,singn) c
where b.no=c.no and singn^=1
having contno=contsn;
%macro sql(no,singn);
proc sql;
create table out1 as
select no,singn
from a
where no=%bquote('&no') and singn=&singn;
proc append base=out data=out1;
run;
%mend;
data _null_;
set bc;
call execute('%sql('||no||','||singn||')');
run;
[/code:39few8io]作者: shiyiming 时间: 2009-10-27 12:19 标题: Re: 急等答案,关于数据集的修改! [code:39yydmyj]data ahuige;
input no $ sign;
cards;
s1 1
s1 1
s2 1
s2 2
s3 1
s3 1
s4 2
s4 2
;
run;
proc sql;
create table final as
select *
from ahuige
group by no
having max(sign) ne 1 or min(sign) ne 1
;[/code:39yydmyj]