Dear JSA,
I did my own macro but I have used it only once, so maybe you should assure that everything works properly.
I you find any error or you have any comment please let me know.
Juan Vicente Torres
torres.j(at)recercaclinica.com
-------------------------------------------------------------------------------------------------------------
/*****************************************************************************
PROGRAM NAME : ./diagnostic_values.sas
PROJECT NAME :
AUTHOR : Juan Vicente Torres
CREATION DATE : 23/04/2008
DESCRIPTION : Calculate Sensibility, Specificity, Positive predictive
values and Negative predictive values
DETAILED REQUIREMENTS:
REQUIREMENTS LOCATION:
INPUT :
OUTPUT :
INFRASTRUCTURE : Windows XP SAS 9.1
PARAMETERS : in : Dateset name
gold_s : indicate gold standard test
test : indicate new test
decimals: set the number of decimals to be used
print : print results (yes or no)
EXAMPLE :
data ex;
input gs test @@;
cards;
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1
0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0
;
run;
proc freq data=ex;
table test*gs;
run;
%diagnostic_values(in=ex, gold_s=gs, test=test, decimals=4);
It is very important assign the subjects with a disorder
with 1 and the healthy subjects with 0.
------------------------------------------------------------------------------
PROGRAM HISTORY
Ver# Date Author Description
---- -------- --------------- -------------------------------------------
001 23/04/2008 J.V Torres Production version
******************************************************************************/
%macro diagnostic_values(in=, gold_s=, test=, decimals=2, print=yes);
proc sort data=&in out=&in.x;
by descending &test descending &gold_s;
run;
%let dec = %eval(&decimals+2).&decimals;
%put ****************** &dec.;
ods select none;
**********************************************************************
Sensitivity;
ods output BinomialProp = BinomialProp;
proc freq data=&in.x order=data;
where &gold_s=1;
tables &test;
exact binomial;
run;
data _null_;
set binomialprop;
if name1 = "_BIN_" then call symput('p' ,put(nValue1,&dec.));
else if name1 = "L_BIN" then call symput('la',put(nValue1,&dec.));
else if name1 = "U_BIN" then call symput('ua',put(nValue1,&dec.));
else if name1 = "XL_BIN" then call symput('le',put(nValue1,&dec.));
else if name1 = "XU_BIN" then call symput('ue',put(nValue1,&dec.));
run;
data _dp;
length param $35.;
param = 'Sensitivity';
p = put(&p,&dec.);
ainterval = "(&la-&ua)";
einterval = "(&le-&ue)";
label param = 'Parameter'
p = 'Estimation'
ainterval = 'Assimptotic 95% C.I'
einterval = 'Exact 95% C.I';
run;
**********************************************************************
Specificity;
ods output BinomialProp = BinomialProp;
proc freq data=&in.x;
where &gold_s=0;
tables &test;
exact binomial;
run;
data _null_;
set binomialprop;
if name1 = "_BIN_" then call symput('p',put(nValue1,&dec.));
else if name1 = "L_BIN" then call symput('la',put(nValue1,&dec.));
else if name1 = "U_BIN" then call symput('ua',put(nValue1,&dec.));
else if name1 = "XL_BIN" then call symput('le',put(nValue1,&dec.));
else if name1 = "XU_BIN" then call symput('ue',put(nValue1,&dec.));
run;
data _dp_aux;
length param $35.;
param = 'Specificity';
p = put(&p,&dec.);
ainterval = "(&la-&ua)";
einterval = "(&le-&ue)";
label param = 'Parameter'
p = 'Estimation'
ainterval = 'Assimptotic 95% C.I'
einterval = 'Exact 95% C.I';
run;
data _dp;
set _dp _dp_aux;
run;
**********************************************************************
Positive predictive value;
ods output BinomialProp = BinomialProp;
proc freq data=&in.x order=data;
where &test=1;
tables &gold_s;
exact binomial;
run;
data _null_;
set binomialprop;
if name1 = "_BIN_" then call symput('p',put(nValue1,&dec.));
else if name1 = "L_BIN" then call symput('la',put(nValue1,&dec.));
else if name1 = "U_BIN" then call symput('ua',put(nValue1,&dec.));
else if name1 = "XL_BIN" then call symput('le',put(nValue1,&dec.));
else if name1 = "XU_BIN" then call symput('ue',put(nValue1,&dec.));
run;
data _dp_aux;
length param $35.;
param = 'Positive predictive value';
p = put(&p,&dec.);
ainterval = "(&la-&ua)";
einterval = "(&le-&ue)";
label param = 'Parameter'
p = 'Estimation'
ainterval = 'Assimptotic 95% C.I'
einterval = 'Exact 95% C.I';
run;
data _dp;
set _dp _dp_aux;
run;
**********************************************************************
Negative predictive value;
ods output BinomialProp = BinomialProp;
proc freq data=&in.x;
where &test=0;
tables &gold_s;
exact binomial;
run;
data _null_;
set binomialprop;
if name1 = "_BIN_" then call symput('p',put(nValue1,&dec.));
else if name1 = "L_BIN" then call symput('la',put(nValue1,&dec.));
else if name1 = "U_BIN" then call symput('ua',put(nValue1,&dec.));
else if name1 = "XL_BIN" then call symput('le',put(nValue1,&dec.));
else if name1 = "XU_BIN" then call symput('ue',put(nValue1,&dec.));
run;
data _dp_aux;
length param $35.;
param = 'Negative predictive value';
p = put(&p,&dec.);
ainterval = "(&la-&ua)";
einterval = "(&le-&ue)";
label param = 'Parameter'
p = 'Estimation'
ainterval = 'Assimptotic 95% C.I'
einterval = 'Exact 95% C.I';
run;
data _dp;
set _dp _dp_aux;
run;
ods select all;
%if %upcase(&print) = YES %then %do;
*title 'Diagnostic parameters';
proc report missing headline headskip nowd split="@" data=_dp ;
columns param p ainterval einterval ;
define param / display %w(36) order order=data;
define p / display %w(10);
define ainterval / display %w(21);
define einterval / display %w(15);
run;
%end;
%mend;
... View more