data b1;
set b;
by c;
if first.c;
run;作者: shiyiming 时间: 2012-4-4 04:28 标题: Re: 怎样用data step,而不是sql得出不重复数据? [code:1v2bq1q8]data a;
input c $ @@;
cards;
a ab a ab abc
;
proc sort data = a out = b nodup;
by c;
run;[/code:1v2bq1q8]作者: shiyiming 时间: 2012-4-5 09:24 标题: Re: 怎样用data step,而不是sql得出不重复数据? [quote="gogotiger":396ns60f][code:396ns60f]data a;
input c $ @@;
cards;
a ab a ab abc
;
proc sort data = a out = b nodup;
by c;
run;[/code:396ns60f][/quote:396ns60f]
谢谢!但,有没有办法在data step里面输出,输出成一个data set的呢?作者: shiyiming 时间: 2012-4-5 14:06 标题: Re: 怎样用data step,而不是sql得出不重复数据? 以上代码不就是输出 b的数据集么作者: shiyiming 时间: 2012-9-3 13:55 标题: Re: 怎样用data step,而不是sql得出不重复数据? [quote="gogotiger":2yoolu79][code:2yoolu79]data a;
input c $ @@;
cards;
a ab a ab abc
;
proc sort data = a out = b nodup;
by c;
run;[/code:2yoolu79][/quote:2yoolu79]这个方法可以!作者: shiyiming 时间: 2012-9-3 14:55 标题: Re: 怎样用data step,而不是sql得出不重复数据? [code:3qp6ug2s]
data a;
input c $ @@;
cards;
a ab a ab abc
;
proc sort data=a;
by c;
run;
data b;
set a;
by c;
if first.c and last.c;
run;
[/code:3qp6ug2s]作者: shiyiming 时间: 2012-9-13 09:39 标题: Re: 怎样用data step,而不是sql得出不重复数据? 如果不先sort可以考虑一下:京剧
[code:g7pgis8v]data have2;
set have; by name notsorted;
array t[1000] $ _temporary_;
if first.name then do;
n ++1;t[n] =name;
if _n_ >1 then do i =1 to n -1;
if name =t[i] then do;
n +-1; i =0; leave;
end;
end;
if ( i | _n_ =1) then output;
end;
run;[/code:g7pgis8v]作者: shiyiming 时间: 2012-9-13 13:10 标题: Re: 怎样用data step,而不是sql得出不重复数据? 试一下 Hash Table 吧
[code:3vsoljzv]
data ads;
input x $;
datalines;
a
ab
a
ab
abc
;
data _null_;
length x $ 8;
if _N_ = 1 then do;
declare Hash ht(dataset:'work.ads',ordered:'a');
ht.defineKey('x');
ht.defineData('x');
ht.defineDone();
call missing(x);
end;
rc=ht.output(dataset:'bds');
run;
[/code:3vsoljzv]作者: shiyiming 时间: 2012-9-19 13:31 标题: Re: 怎样用data step,而不是sql得出不重复数据? 同样一个问题,能得到这么多的回答。高手如云呐。作者: shiyiming 时间: 2012-9-22 10:12 标题: Re: 怎样用data step,而不是sql得出不重复数据? [code:1li7uykb]
data a;
input code $ @@;
cards;
a ab a ab abc
;
proc sort data=a out=b nodupkey;
by code ;
run;
[/code:1li7uykb]