SAS软件,cox回归分析配对病例对照的代码是什么?
时间: 2024-05-09 19:19:20 浏览: 186
sas回归分析代码
以下是在SAS中进行配对病例对照的Cox回归分析的示例代码:
```
/* 导入数据 */
data mydata;
infile 'mydata.csv' delimiter=',' firstobs=2;
input group $ id time status covariate1 covariate2;
run;
/* 对照组匹配 */
proc sort data=mydata;
by group covariate1 covariate2 id;
run;
data matched;
set mydata;
by group covariate1 covariate2 id;
retain control_id;
if first.group then control_id=.;
if status=1 and control_id=. then do;
set mydata(keep=id where=(status=0 and group=group and covariate1=covariate1 and covariate2=covariate2)) point=control;
if control then control_id=id;
end;
if status=1 then output;
run;
/* Cox回归分析 */
proc phreg data=matched;
class group;
model time*status(1) = group covariate1 covariate2;
strata control_id;
run;
```
注意,这里假设数据已经按照组别和匹配变量排序,变量名为group、id、time、status、covariate1和covariate2,其中group是分组变量,id是个体标识变量,time是生存时间变量,status是生存状态变量(1表示死亡,0表示存活),covariate1和covariate2是其他的协变量。
阅读全文