data a;
input x iswy;
cards;
0.940278 1
0.838616 0
0.84515 1
0.878174 1
0.88333 1
0.885006 1
;
run;
Proc sort data=a out=a;
by descending x;
run;
data a;
set a;
i=1;
sn+i;
run;
data a;
set a;
wy+iswy;
if iswy=0 then isnotwy=1;
else isnotwy=0;
run;
data a ;set a;
notwy+isnotwy;
run;
proc sql;
create table roc as
select sn,wy/sum(iswy) as y,notwy/sum(isnotwy) as x
from a;
quit;
run;
proc sql;
create table auc as
select sum(y*delta) as auc
from (select a.*,b.x as x2,a.x- b.x as delta
from roc a,roc b
where a.sn=b.sn+1)
;
quit;
run;
/***ROC曲线**/
axis order=(0 to 1 by .1) label=none length=4in;
symbol i=join v=none c=depk;
symbol2 i=join v=none c=black;
title "roc curve";
axis1 label=(angle=90 "sensitivity");
axis2 label=("1-1mspec");
proc gplot data =roc gout=roc;
plot y*x x*x
/ overlay vaxis=axis1 haxis=axis2;
run;
quit;