楼主: qh95253882
2360 3

怎样计算如下格式的数据的用户的登陆时长 [推广有奖]

  • 0关注
  • 0粉丝

已卖:201份资源

本科生

52%

还不是VIP/贵宾

-

威望
0
论坛币
90 个
通用积分
1.0073
学术水平
0 点
热心指数
1 点
信用等级
0 点
经验
108 点
帖子
91
精华
0
在线时间
75 小时
注册时间
2007-4-12
最后登录
2014-5-5

楼主
qh95253882 发表于 2008-11-10 15:20:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币

怎样计算如下格式的数据的用户的登陆时长
操作类型中01表示登陆,02表示下线,操作时间20080701073549 则表示2008年7月1号7点35分49秒

终端类型可以不考虑.


号码        操作类型 终端类型 操作时间
727095283 01 1204 20080701073549
727095283 02 1204 20080701074058
727095283 01 1204 20080701081754
726676742 02 1101 20080701113438
726676742 01 1101 20080701134932
727095283 02 1204 20080701122809
727095283 02 1204 20080701144822
726676742 01 1101 20080701075635
726676742 02 1101 20080701084341
726676742 01 1101 20080701084344
726676742 02 1101 20080701085941
726676742 02 1101 20080701091553
726676742 01 1101 20080701091502
727095283 01 1204 20080701122256
726676742 01 1101 20080701092055
726676742 01 1101 20080701092857
726676742 02 1101 20080701092857
726676742 01 1101 20080701095528
726676742 02 1101 20080701095528
726676742 01 1101 20080701101253
726676742 02 1101 20080701101204
726676742 01 1101 20080701101421

有几个问题值得考虑,由于统计周期的限制,有些用户只有登陆行为数据,没有下线行为数据。
该如何使登陆时长的计算不考虑这些数据啊?(注这个数据集大约有500万条记录啊,所以会有点麻烦啊!)
谢谢各位大侠了啊?


二维码

扫码加我 拉你入群

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

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

关键词:500万 各位大侠 数据集 数据 格式 用户 登陆

回帖推荐

宜桦 发表于4楼  查看完整内容

no comments but hope it is clear enough.proc sort data = rawdata;by id operate_time type ; data good (drop = lag_type type rename = (operate_time = end_time)) need_work1 need_work2;format start_time datetime.;set rawdata ;by id operate_time type;lag_type = lag(type);start_time = lag(operate_time);if first.id then do;      lag_type = '';     ...

本帖被以下文库推荐

沙发
quarky 发表于 2008-11-10 15:33:00
没有下线行为数据,那这次登入是否算登入。没有下线行为数据,如果不算的话,比较好处理。自己写个程序跑下就出来了。
一起学习,一起进步

藤椅
marloneusa 发表于 2008-11-10 23:38:00
你的统计周期是多长, 24hrs  or 一周 or 更长? 如果是一天, 讷么用01's 24:00作为cut-off point, 如果你找不到相应的02.

另外的一种方法就是impute. 分类找到这些客户,回填the missing values.

板凳
宜桦 发表于 2008-11-11 05:30:00

no comments but hope it is clear enough.

proc sort data = rawdata;

by id operate_time type ;

 

data good (drop = lag_type type rename = (operate_time = end_time)) need_work1 need_work2;

format start_time datetime.;

set rawdata ;

by id operate_time type;

lag_type = lag(type);

start_time = lag(operate_time);

if first.id then do;

      lag_type = '';

      start_time = .;

end;

if lag_type = '01' and type = '02' then do;

    format stay time.;

      stay = (operate_time - start_time) ;

    output good;

end;

else if (first.id and type = '02')

     or (type = lag_type) then output need_work1;

else if (last.id and type = '01') then output need_work2;

run;

 

data done_work (keep = id start_time end_time notes);

set need_work1(in = a) need_work2 (in = b);

by id operate_time type;

format notes $ 20. end_time datetime.;

 

if lag_type in ( '', '02') and type = '02' then do;

      notes = 'Missing Start Time';

      end_time = operate_time;

      start_time = .;

end;

 

else if lag_type = '01' and type = '01' then do;

      notes = 'Missing End Time';

end;

 

if b then do;

      notes = 'Non Closed Session';

      start_time = operate_time;

end;

 

run;

 

proc sort data = done_work;

by id start_time;

 

 

data final;

set good (in = g) done_work;

by id start_time;

if g then notes = 'Good Data';

run;

已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-30 01:48