全部版块 我的主页
论坛 站务区 十一区 新手入门区
1442 2
2014-09-22
请教一个问题,我想做的需求是统计一个银行数据,每个用户(ID)每次服务类型(deposit 或者withdraw)的总和,就是每个用户交易类型为deposit的总和是多少,交易类型为withdraw的总和又是多少,可是我跑出来的程序结果总是错误的,统计不对,我真不知道错哪里了,跪求啊,谢谢。

data zsh;
     input ID $ date:date9. type $;
     format date:date9.;
     cards;
0001 01may2001 deposit
0002 01may2001 withdraw
0003 02may2001 withdraw
0001 18may2001 deposit
0001 27may2001 deposit
0002 27may2001 deposit
0003  04may2001 withdraw
;
run;
proc sort data=zsh out=zsh2;
     by ID type;
run;

data zsh3;
      set zsh2;
      by id type;
      retain num 0 odd 0;
      if first.id then do;
         if type='deposit' then num=1;
         else if type='withdraw' then odd=1;
         end;
      else do;
         if type='deposit' then num+1;
         else if type='withdraw' then odd+1;
         end;

      if last.id then output;
run;



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2014-9-22 12:24:42
结果如图
附件列表
无标题.png

原图尺寸 2.65 KB

无标题.png

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-9-23 02:13:36
the result is not correct,may I get some help for the program?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群