在sas/hash中碰到下面一个问题,一直苦于无法解决,请各位大虾帮忙:
例如(实际客户上万个):A客户有三条记录,每条记录的金额均小于200,;B客户有5条记录,每条记录的金额均大于150,但小于400。
在hash中,如何实现下面条件?
条件:如果某个客户的总金额(该客户所有记录的金额加和)<600,则将该客户的所有记录删除。
如上例中,A客户总金额<600,则删除A客户。
不用sql解决,只用sas/hash解决,并且一步实现

|
楼主: flyinglancet
|
7752
9
[问答] sas hash表的 汇总问题 |
|
硕士生 13%
-
|
回帖推荐data test;
input id $ amount;
datalines;
A 189
B 160
B 188
B 165
A 145
A 199
B 198
B 345
;
data wanted;
if 0 then set test;
if _n_=1 then do;
declare hash h();
h.definekey('id');
h.definedata('id','total');
h.definedone();
end;
do until(last);
set test end=last;
if h.find()=0 then do;
total+amount;
h.rep ...
本帖被以下文库推荐
| ||
|
|
| ||
|
和谐拯救危机
|
||
| ||
| ||
|
和谐拯救危机
|
||
| ||
| ||
加好友,备注cda京ICP备16021002号-2 京B2-20170662号
京公网安备 11010802022788号
论坛法律顾问:王进律师
知识产权保护声明
免责及隐私声明


