全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
2766 19
2013-09-28
各位大侠:
      有如下问题请教:
病人编号服药日期治疗剂量当天服药次数

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


数据介绍:本研究期限为13天,以服药时间为据;问题--关于服药天数变量的挑选:
1、如果在研究期限内病人连续7天(>=7天)不服药(3号标红日期),而不是超过研究期限的5号病人,则生成新变量”status“=1,其他为=0,不存在断断续续服药情况(服药间隔<7天)如4号则变量”是否漏服“=0
2、如果在研究期限内存在连续7天不服药的情况,同时还存在断断续续服药情况如4号,则生成新变量status=1,”是否漏服“=1
所有病人计算实际服药天数,如1号病人=1天  2号=3天  3号=2天 4号=3天  5号=13天(虽然其大于13天)
问题--关于服药剂量
1、如果研究期限内病人剂量无调整--如1号,则”调整次数“=0   ”平均剂量“=25     ”平均调整剂量“=0
2、2号病人在研究期限内1天服2次药,则计算服药天数时”2006-10-1“为1天,当日剂量为2次之和。则”调整次数“(调整次数-----1天之内的调整不计入调整次数如2号)=1   ”平均剂量“=33+30/2     ”平均调整剂量“=3
3、3号病人”调整次数“=2    ”平均剂量“=30+10+35/3    ”平均调整剂量“=第一次从30变为10的20+25/2次调整
4、4号病人”调整次数“=2    ”平均剂量“=30+10+30/3     ”平均调整剂量“=20+20/2次
总结:最后每一个病人都要得到如下变量
”实际服药天数“  ”status“  ”是否漏服“   ”调整次数“  ”平均剂量“   ”平均调整剂量“






二维码

扫码加我 拉你入群

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

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

全部回复
2013-9-28 01:07:34
路过
二维码

扫码加我 拉你入群

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

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

2013-9-29 11:23:04
是这样吗?

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>7 then do; status=1; miss=1;end;
else do; status=0; miss=0;end;
format date1 yymmdd10.;
drop dose_;
run;

proc sql;
* status, missing dose;
create table status as
select distinct subjid, status, miss
from test3
where status=1 and miss=1
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 adjtime mean adjmean;
  by subjid;
  if status=. then status=0;
  if miss=. then miss=0;
run;
二维码

扫码加我 拉你入群

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

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

2013-9-30 14:36:17
问题一:
复制代码
二维码

扫码加我 拉你入群

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

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

2013-9-30 15:47:54
问题二
复制代码
二维码

扫码加我 拉你入群

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

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

2013-9-30 19:33:11
wwang111 发表于 2013-9-29 11:23
是这样吗?

data test;
    非常谢谢你的回答,程序简洁,很细心写了注释!应该是这样的,有一点点小问题,就是“stutas” 和“miss”两个变量不够准确,附上程序处理的结果,及更改后的结果;
subjid         actdate        status        miss              adjtime        mean               adjmean
1         1                  0                  0                    0                   25                           0
2         3                  0                  0 1              1                   31.5                   3
3         2                  1                  1 0                    2                   25                           22.5
4         3                  0 1                  0 1                    2                   23.33333333           20
5         13                  0                  0                    8                   32.77777778            3.125
更正的“status" "miss"写在旁边,我觉得的可能的原因为2号病人的最后一次服药时间,跟3号第一天服药时间相同,所以lag函数的取值有点不够准确,我再试试!可能是我的问题说的不够清楚!  我怎么把币给你了?
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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