楼主: zhengfamily1979
1491 2

[求助] 请大家帮看一个简单的SAS编程,不知道出错哪里 [推广有奖]

  • 0关注
  • 0粉丝

学前班

80%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
33 点
帖子
2
精华
0
在线时间
3 小时
注册时间
2014-4-15
最后登录
2015-2-21

楼主
zhengfamily1979 发表于 2014-9-22 12:14:25 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
请教一个问题,我想做的需求是统计一个银行数据,每个用户(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;



二维码

扫码加我 拉你入群

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

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

关键词:SAS编程 不知道 withdraw Deposit format deposit 程序 统计 用户

沙发
yunzhonghai 发表于 2014-9-22 12:24:42
结果如图

无标题.png (2.65 KB)

无标题.png

藤椅
zhengfamily1979 发表于 2014-9-23 02:13:36
the result is not correct,may I get some help for the program?

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
jg-xs1
拉您进交流群
GMT+8, 2026-1-3 18:03