楼主: tanaya
2387 19

[有偿编程] 多变量大数据整理,如何编程进行数据挖掘?报酬15个币!其他算帮忙吧! [推广有奖]

11
tanaya 发表于 2013-10-9 10:55:26 |只看作者 |坛友微信交流群
lifemg 发表于 2013-10-3 23:42
mark下 一有时间就来整
谢谢!欢迎讨论!

使用道具

12
wwang111 发表于 2013-10-9 11:09:39 |只看作者 |坛友微信交流群
tanaya 发表于 2013-10-9 10:51
谢谢你对这件事如此上心,我发现根源在于我没有把问题阐述的非常清楚清楚,
status(是否脱失):连续7天 ...
我的问题是4号的研究期是10月7号到10月19号,为期13天,不包括20号,数据里那条10月20号是属于超期服药的,就相当于5号的10月23号和11月2号,如果是超期服药,那一条就没有存在的意义了,所以7天的界限不应该把那一天包括进去。这样的话2号和4号就是同样的情况了。
只有一个罗纳尔多

使用道具

13
龙潭丰乐 学生认证  发表于 2013-10-9 12:24:23 |只看作者 |坛友微信交流群
tanaya 发表于 2013-10-9 10:54
谢谢你的回答,只是其中有些变量不知道是代表哪一行数字,也不知道变量的变换过程,如freqency\quali ...
可能我之前没有完全理解你的意思,所以问题一弄的比较复杂。但是这个问题 还挺有意思的

使用道具

14
tanaya 发表于 2013-10-9 15:16:14 |只看作者 |坛友微信交流群
龙潭丰乐 发表于 2013-10-9 12:24
可能我之前没有完全理解你的意思,所以问题一弄的比较复杂。但是这个问题 还挺有意思的
我还有一些有意思的数据,到时候,欢迎讨论!不知道你现在理解了没?其实@wwang111的程序已经比较简洁易懂了,如有高见欢迎继续讨论!

使用道具

15
tanaya 发表于 2013-10-9 15:21:34 |只看作者 |坛友微信交流群
wwang111 发表于 2013-10-9 11:09
我的问题是4号的研究期是10月7号到10月19号,为期13天,不包括20号,数据里那条10月20号是属于超期服药的 ...
4号的status你是对的,20号超过研究期限了,谢谢指正,miss应该为1吧?

使用道具

16
wwang111 发表于 2013-10-9 19:09:07 |只看作者 |坛友微信交流群
tanaya 发表于 2013-10-9 15:21
4号的status你是对的,20号超过研究期限了,谢谢指正,miss应该为1吧?
这里的status,如果只考虑研究期限内的数据,我觉得2号和4号应该是属于同一种情况。
miss没有问题,你上次给出的答案是对的,我明天把我的程序粘上来,你再看一下有没有问题。
只有一个罗纳尔多

使用道具

17
龙潭丰乐 学生认证  发表于 2013-10-9 21:28:51 |只看作者 |坛友微信交流群
tanaya 发表于 2013-10-9 15:16
我还有一些有意思的数据,到时候,欢迎讨论!不知道你现在理解了没?其实@wwang111的程序已经比较简洁易懂 ...
恩恩  理解了  继续玩转sas,玩转数据

使用道具

18
wwang111 发表于 2013-10-10 08:25:17 |只看作者 |坛友微信交流群
这是我更新后的程序,你看看有什么问题。

data test;
input subjid date: yymmdd10. dose time;
format date yymmdd10.;
cards;
1 2006-9-30 25 1
2 2006-10-1 15 1
2 2006-10-1 18 2
2 2006-10-3 30 1
2 2006-10-4 30 1
3 2006-10-4 30 1
3 2006-10-5 10 1
3 2006-10-13 35 1
4 2006-10-7 30 1
4 2006-10-9 10 1
4 2006-10-12 30 1
4 2006-10-20 30 1
5 2006-10-10 30 1
5 2006-10-11 30 1
5 2006-10-12 10 1
5 2006-10-13 70 1
5 2006-10-14 25 1
5 2006-10-15 30 1
5 2006-10-16 30 1
5 2006-10-17 45 1
5 2006-10-18 30 1
5 2006-10-19 20 1
5 2006-10-20 35 1
5 2006-10-21 35 1
5 2006-10-22 35 1
5 2006-10-23 35 1
5 2006-11-2 35 1
;
* pick up the valid treatment phase;
proc sql;
create table test1 as
select *  from test
group by subjid
having date < min(date)+13
order by subjid,date,time;
quit;
* combine the subjects who dose two times a day;
data test2;
set test1;
by subjid date time;
retain dose_;
if first.date then dose_=dose;
else dose+dose_;
if last.date;
run;
* compare the date and dose from this time to next time;
data test3;
set test2;
by subjid date time;
date1=lag(date);
dose1=lag(dose);
if first.subjid then do; date1=.; dose1=.; end;
if first.subjid and last.subjid then do; date1=date; dose1=dose; flag=1;end;
if date1 ne . and date-date1+1>7 then status=1;
if status=. then status=0;
if date-date1+1<=7 and date-date1>1 then miss=1;
else miss=0;
format date1 fdate yymmdd10.;
drop dose_;
run;

proc sql;
* status, missing dose;
create table status as
select distinct subjid, status
from test3
group by subjid
having status=max(status)
order by subjid;

create table miss as
select distinct subjid, miss
from test3
group by subjid
having miss=max(miss)
order by subjid;

* actual dose date;
create table actdate as
select subjid, count(distinct date) as actdate
from test3
where  date-date1<=7
group by 1
order by 1;

* mean dose;
create table mean as
select distinct subjid, ifn(flag=1,dose,mean(dose)) as mean
from test3
where flag=1 or  dose ne dose1
group by 1
order by 1;

* adjust time;
create table adjtime as
select distinct subjid,ifn(flag=1,0,count(distinct date1)) as adjtime
from test3
where flag=1 or (dose1 ne . and dose ne dose1)
group by 1
order by 1;

* adjust mean;
create table adjmean as
select a.subjid, ifn(n=0,0,(a.n/b.adjtime)) as adjmean from
(select distinct subjid, ifn(flag=1,0,sum(abs(dose-dose1))) as n
from test3
where flag=1 or (dose1 ne . and dose ne dose1)
group by 1) a
join adjtime b
on a.subjid=b.subjid
order by a.subjid;
quit;

* final dateset;
data final;
merge actdate status miss adjtime mean adjmean;
  by subjid;
run;
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
tanaya + 1 + 1 + 1 热心帮助其他会员

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

只有一个罗纳尔多

使用道具

19
tanaya 发表于 2013-10-10 09:29:47 |只看作者 |坛友微信交流群
wwang111 发表于 2013-10-10 08:25
这是我更新后的程序,你看看有什么问题。

data test;
刚运行了你提供的更新程序,很完美,非常感谢!
查了一下关于奖励论坛币的帖子,非管理权限的会员如我,需要你设置标价的附件,我去购买即可。关于设置:https://bbs.pinggu.org/thread-1155160-1-1.html    请参照这个帖子!  谢谢!

使用道具

20
wwang111 发表于 2013-10-10 12:07:52 |只看作者 |坛友微信交流群
tanaya 发表于 2013-10-10 09:29
刚运行了你提供的更新程序,很完美,非常感谢!
查了一下关于奖励论坛币的帖子,非管理权限的会员如我, ...
论坛币就不用了
只有一个罗纳尔多

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-28 12:21