Commit 3fe72982 authored by Paul Brown's avatar Paul Brown

Upload New File

parent f2e258b5
/******************************************************************************
Author, date: Paul Brown, JUL2015
Macro name: lrscore (calculate log rank scores for the TTE outcomes),
derive_ZS (derive the average z-score)
Description: derive the average z-score on simulated data of up to 5 outcomes.
The macro expects a dataset of &num random samples indicated by
the variable sum=1,2,...num (developed in SAS 9.4)
Reference: Evaluating Treatment Efficacy by Multiple End Points in Phase II
Acute Heart Failure Clinical Trials: Analyzing Data Using a Global Method
Sun et al. Circulation: Heart Failure, 2012
******************************************************************************/
********************************************************************;
*** derive log rank scores ***;
********************************************************************;
%macro lrscore(in_,var,cens,lrsvar);
data lrstmp;
set _null_;
run;
%do i=1 %to &gnum; /*do for each random sample*/
proc lifetest data=&in_ (where=(samp=&i))
outsurv=outsurv plots=none noprint;
time &var*&cens(1);
run;
data outsurv2;
retain survival2 ;
set outsurv (where=(survival ne 1));
if survival eq . then survival=survival2;
else survival2=survival;
if survival ne . then &var.ch=-log(survival);
else &var.ch=0; /*with sml samples sometimes no failures, z=0*/
samp=&i;
keep samp &var &var.ch;
run;
proc sort data=outsurv2 nodupkey; /*duplicates if tied surv times*/
by &var;
run;
data lrstmp;
set lrstmp outsurv2;
run;
%end;
proc sort data=&in_ (keep=samp subjno &var &cens)
out=survtimes;
by samp &var;
run;
data lrs;
merge lrstmp survtimes;
by samp &var;
&lrsvar=abs(&cens-1)-&var.ch;
keep samp subjno &lrsvar;
run;
proc sort data=lrs;
by samp subjno;
run;
%mend lrscore;
********************************************************************;
*** derive z-scores ***;
********************************************************************;
%macro derive_ZS(indata=finalsamp,outdata=out_zs,outpval=pval_zs,
desc1=d,desc2=d,desc3=d,desc4=,desc5=d
/*desc: indicate whether high values are good or bad,
for LR scores a high value is bad*/);
data readyforz;
set &indata;
keep samp subjno trt;
run;
%do h=1 %to &gnumvars;
%if &&gtype&h=SURV %then %do;
%lrscore(&indata,var&h.2,var&h.c,varz&h); /*convert survival times to log rank scores*/
data readyforz;
merge readyforz lrs;
by samp subjno;
label varz&h="var&h Logrank score";
run;
%end;
%else %if &&gtype&h=LOGN %then %do;
data readyforz;
merge readyforz &indata (keep=samp subjno var&h);
by samp subjno;
varz&h=log(1+var&h/100); /*convert from pct change to log odds*/
drop var&h;
label varz&h="var&h Log ratio";
run;
%end;
%else %do;
data readyforz;
merge readyforz &indata (keep=samp subjno var&h);
by samp subjno;
rename var&h=varz&h;
run;
%end;
%end;
*derive z-scores (for small samples and low event rates may have var=0);
proc stdize data=readyforz out=zscores;
var var:;
by samp; /*not by trt*/
run;
********************************************************************;
*** derive average z-score ***;
********************************************************************;
data &outdata;
set zscores;
*align z-scores (ie so high values indicate a good response);
%do h=1 %to &gnumvars;
%if &&desc&h=d %then %do;
varz&h=-varz&h;
%end;
%end;
zscore=sum(of varz1-varz&gnumvars)/&gnumvars;
keep samp subjno trt zscore varz1-varz&gnumvars;
label zscore='Average z-score';
run;
********************************************************************;
*** p-value ***;
********************************************************************;
ods output KruskalWallisTest=&outpval
(where=(name1='P_KW') keep=samp variable nValue1 name1) ;
proc npar1way data=&outdata wilcoxon plots=none ;
ods select KruskalWallisTest ;
class trt;
var zscore ;
by samp;
quit;
%mend derive_ZS;
***end****************************************************************;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment