|
|
地板

楼主 |
发表于 2010-7-27 09:59:00
|
只看该作者
Re: 就是不同!
gzgoon完全正确。
下面可以证明,我提供了第三种方法,也是用的data步,结果充分说明data步和sql对浮点处理方式不一样,data步考虑到小数位比sql多,但是据我的经验,公司一般用data步来处理此类数据。
[code:1maeoe50]data dup;
input id date field value ;
cards;
1 2 0.0001 10
1 2 0.0001 10
1 2 0.00001 10
1 2 0.00001000001 10
1 3 0.00001 10
1 3 0.00001 10
1 3 0.00003 10
1 3 0.00003 10
1 3 0.00003 10
;
run;
proc sql; *Use average to repalce multiple values at same id,date and field;
create table NoDup1 as
select unique id, date, field, avg(value) as value from Dup group by id, date, field;
quit; *191035;
*method 2;
proc means data = Dup nway ;
class id date field;
var value;
output out = NoDup2(drop = _type_ _freq_) mean = value;
run; *191030;
proc sort data=dup out=dup;
by id date field;
data nodup3;
set dup;
by id date field;
if first.field then do; num=0;mean=0;end;
num+1; mean+value;
if last.field then do; value=mean/num; output; end;
run;[/code:1maeoe50]
ps:jingju老大,我拜托的事,怎么样了? <!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D --> |
|