嗨SAS人,
我正在使用医院访问数据开展一些研究项目。我必须确定转换治疗的受试者。
治疗按局部,非生物系统和生物学分组。切换事件被定义为在最后一次治疗取出时未取出的药物的撤回。有一个层次结构,生物制剂位于顶部,然后是非生物系统,然后是局部。
根据上述逻辑,一旦患者转为更高级别的治疗,较低等级被认为是伴随用药,并且同时用药的撤销并不表示治疗开关。
简而言之,如果患者从较低级别的治疗转为上级或同一级别(不同的ATC代码),那么将考虑转换。
生物制剂> Non_Bio_Sys>主题
我正在为参考添加样本数据集,其中包含可变信息:
LPNR: unique subjID
EDATUM: prescrition date ( treatment recieved date)
ATC_CODE: codes for each of treament type
'D05AX52',
'D05AX02' = PSorasis(Topical) ;
'L01XC02',
'L04AA24',
'L04AB01',
'L04AB02',
'L04AB04',
'L04AB05',
'L04AB06',
'L04AC03',
'L04AC07' = Non_Bio_systemic ;
'A11CC03',
'D05BB02',
'L01BA01',
'L01BB03',
'L01XX05',
'L04AA21',
'L04AD01',
'L04AX03' = Biologics ;
TYPE: Treatment type
data have;
length TYPE $20.;
input pnr ATC_CODE $ type $ EDATUM $ 10. ;
date=input(edatum,mmddyy10.);
format date mmddyy10.;
cards;
478 L04AX03 Nonbiologic_systemic 2/10/2010
478 D05AX52 Psoriasis 2/23/2010
478 L04AX03 Nonbiologic_systemic 3/5/2010
478 L04AX03 Nonbiologic_systemic 5/18/2010
478 L04AX03 Nonbiologic_systemic 8/2/2010
478 L04AX03 Nonbiologic_systemic 11/3/2010
478 L04AX03 Nonbiologic_systemic 2/7/2011
478 L04AX03 Nonbiologic_systemic 8/16/2011
478 L04AX03 Nonbiologic_systemic 11/22/2011
603 D05AX02 Psoriasis 8/24/2005
603 D05AX02 Psoriasis 10/13/2005
603 D05AX02 Psoriasis 6/2/2006
603 D05AX02 Psoriasis 7/19/2006
603 D05AX02 Psoriasis 4/3/2007
603 D05AX02 Psoriasis 12/7/2007
603 D05AX02 Psoriasis 1/4/2008
603 D05AX02 Psoriasis 1/4/2008
603 D05AX02 Psoriasis 10/2/2008
603 D05AX52 Psoriasis 3/16/2009
603 D05AX52 Psoriasis 3/16/2009
603 D05AX52 Psoriasis 5/7/2009
603 D05AX52 Psoriasis 8/21/2009
603 D05AX52 Psoriasis 11/9/2009
603 D05AX52 Psoriasis 3/19/2010
603 D05AX52 Psoriasis 7/30/2010
603 D05AX52 Psoriasis 7/30/2010
603 D05AX52 Psoriasis 1/13/2011
603 D05AX52 Psoriasis 5/3/2011
603 D05AX52 Psoriasis 12/12/2011
1103 L04AX03 Nonbiologic_systemic 1/17/2006
1103 L04AX03 Nonbiologic_systemic 8/23/2006
1103 L04AX03 Nonbiologic_systemic 11/9/2006
1103 D05AX52 Psoriasis 4/19/2007
1103 L04AX03 Nonbiologic_systemic 4/19/2007
1103 D05AX52 Psoriasis 10/26/2007
1103 D05AX52 Psoriasis 4/1/2008
1103 L04AX03 Nonbiologic_systemic 10/20/2008
1103 D05AX52 Psoriasis 10/20/2008
1103 L04AX03 Nonbiologic_systemic 4/7/2009
1103 L04AX03 Nonbiologic_systemic 11/20/2009
1103 L04AX03 Nonbiologic_systemic 11/12/2010
1103 L04AX03 Nonbiologic_systemic 8/12/2011
1103 D05AX52 Psoriasis 10/22/2011
1103 D05AX52 Psoriasis 12/29/2011
;
proc sort data=have;
by pnr date;
run;
/* Identifying the number of subjects who had treatment switch */
data need;
set have;
length change $ 10.;
by pnr;
/* Create new variable change and keep constant if it is topical for first observation */
/* Compare topical values with next values if it changes to other non bio or bio then switched */
if first.pnr and atc_code in ( 'D05AX52','D05AX02') then change="";
else if not first.pnr and atc_code not in('D05AX52','D05AX02','L01XC02','L04AA24','L04AB01',
'L04AB02','L04AB04','L04AB05','L04AB06','L04AC03',
'L04AC07','A11CC03','D05BB02','L01BA01','L01BB03',
'L01XX05' ,'L04AA21' ,'L04AD01' ,'L04AX03') then change='switched';
/* Compare non bio values with next values if it changes to other non bio or bio then switched*/
if first.pnr and atc_code in ('L01XC02','L04AA24','L04AB01','L04AB02','L04AB04',
'L04AB05','L04AB06','L04AC03','L04AC07') then change="";
else if not first.pnr and atc_code not in( 'D05AX52','D05AX02') and
atc_code in('L01XC02','L04AA24','L04AB01','L04AB02','L04AB04','L04AB05',
'L04AB06','L04AC03','L04AC07','A11CC03','D05BB02','L01BA01',
'L01BB03' ,'L01XX05' ,'L04AA21' ,'L04AD01' ,'L04AX03') then change='switched';
/* Compare bio with next values if it changes to other bio then switched */
if first.pnr and atc_code in('A11CC03','D05BB02','L01BA01','L01BB03' ,'L01XX05' ,
'L04AA21' ,'L04AD01' ,'L04AX03') then change='';
else if not first.pnr and atc_code not in('D05AX52','D05AX02') and
atc_code in('A11CC03','D05BB02','L01BA01','L01BB03' ,'L01XX05',
'L04AA21' ,'L04AD01' ,'L04AX03') then change='switched';
if atc_code=lag(atc_code) then change="";
run;
pnr ATC_CODE TYPE EDATUM Flag_switch
478 L04AX03 Nonbiologic_systemic 2/10/2010
478 D05AX52 Psoriasis 2/23/2010
478 L04AX03 Nonbiologic_systemic 5/18/2010 switch
478 L04AX03 Nonbiologic_systemic 8/2/2010
478 L04AX03 Nonbiologic_systemic 11/3/2010
478 L04AX03 Nonbiologic_systemic 2/7/2011
478 L04AX03 Nonbiologic_systemic 8/16/2011
478 L04AX03 Nonbiologic_systemic 11/22/2011
603 D05AX02 Psoriasis 8/24/2005
603 D05AX02 Psoriasis 10/13/2005
603 D05AX02 Psoriasis 6/2/2006
603 D05AX02 Psoriasis 7/19/2006
603 D05AX02 Psoriasis 4/3/2007
603 D05AX02 Psoriasis 12/7/2007
603 D05AX02 Psoriasis 1/4/2008
603 D05AX02 Psoriasis 10/2/2008
603 D05AX52 Psoriasis 3/16/2009 switch
603 D05AX52 Psoriasis 5/7/2009
603 D05AX52 Psoriasis 8/21/2009
603 D05AX52 Psoriasis 11/9/2009
603 D05AX52 Psoriasis 3/19/2010
603 D05AX52 Psoriasis 7/30/2010
603 D05AX52 Psoriasis 1/13/2011
603 D05AX52 Psoriasis 5/3/2011
603 D05AX52 Psoriasis 12/12/2011
1103 L04AX03 Nonbiologic_systemic 1/17/2006
1103 L04AX03 Nonbiologic_systemic 8/23/2006
1103 L04AX03 Nonbiologic_systemic 11/9/2006
1103 L04AX03 Nonbiologic_systemic 4/19/2007
1103 D05AX52 Psoriasis 10/26/2007
1103 D05AX52 Psoriasis 4/1/2008
1103 L04AX03 Nonbiologic_systemic 10/20/2008 switch
1103 D05AX52 Psoriasis 10/20/2008
1103 L04AX03 Nonbiologic_systemic 4/7/2009 switch
1103 L04AX03 Nonbiologic_systemic 11/20/2009
1103 L04AX03 Nonbiologic_systemic 11/12/2010
1103 L04AX03 Nonbiologic_systemic 8/12/2011
1103 D05AX52 Psoriasis 10/22/2011
1103 D05AX52 Psoriasis 12/29/2011
答案 0 :(得分:1)
好。所以这是几种可能的解决方案中的一种。您仍然需要计算出治疗类型3(生物制剂)的开关,并找出如何处理同一日期有多个条目的地方。但这应该让你去!
proc format;
value treatType 1 = "Topical"
2 = "Non-biologic systemics"
3 = "Biologics";
run;
data have;
format pnr 8. tType treatType. tCode $10. date YYMMDDs8.;
informat tType 1. date yymmdd10.;
input pnr tCode tType date;
datalines;
478 L04AX03 2 2010-02-10
478 D05AX52 1 2010-02-23
478 L04AX03 2 2010-03-05
478 L04AX03 2 2010-05-18
478 L04AX03 2 2010-08-02
478 L04AX03 2 2010-11-03
478 L04AX03 2 2011-02-07
478 L04AX03 2 2011-08-16
478 L04AX03 2 2011-11-22
603 D05AX02 1 2005-08-24
603 D05AX02 1 2005-10-13
603 D05AX02 1 2006-06-02
603 D05AX02 1 2006-07-19
603 D05AX02 1 2007-04-03
603 D05AX02 1 2007-12-07
603 D05AX02 1 2008-01-04
603 D05AX02 1 2008-01-04
603 D05AX02 1 2008-10-02
603 D05AX52 1 2009-03-16
603 D05AX52 1 2009-03-16
603 D05AX52 1 2009-05-07
603 D05AX52 1 2009-08-21
603 D05AX52 1 2009-11-09
603 D05AX52 1 2010-03-19
603 D05AX52 1 2010-07-30
603 D05AX52 1 2010-07-30
603 D05AX52 1 2011-01-13
603 D05AX52 1 2011-05-03
603 D05AX52 1 2011-12-12
1103 L04AX03 2 2006-01-17
1103 L04AX03 2 2006-08-23
1103 L04AX03 2 2006-11-09
1103 D05AX52 1 2007-04-19
1103 L04AX03 2 2007-04-19
1103 D05AX52 1 2007-10-26
1103 D05AX52 1 2008-04-01
1103 L04AX03 2 2008-10-20
1103 D05AX52 1 2008-10-20
1103 L04AX03 2 2009-04-07
1103 L04AX03 2 2009-11-20
1103 L04AX03 2 2010-11-12
1103 L04AX03 2 2011-08-12
1103 D05AX52 1 2011-10-22
1103 D05AX52 1 2011-12-29
run;
proc sort data=have;
by pnr date;
run;
data want;
set have;
by pnr;
format switch 1. tCode_prev $10. tType_prev 3.;
retain tCode_prev '' tType_prev .;
format switch 1.;
if first.pnr then do;
switch = 0;
end;
else if tType_prev = 1 then do;
if tType > 1 or tCode ne tCode_prev then switch = 1;
else switch = 0;
end;
else if tType_prev = 2 then do;
if tType > 2 or (tType = 2 and tCode ne tCode_prev) then switch = 1;
else switch = 0;
end;
else if tType_prev = 3 then do;
/* Here's your homework */
end;
output;
tCode_prev = tCode;
tType_prev = tType;
drop tCode_prev tType_prev;
run;