* Bland Altman Example Analysis * Code by Alan Elliott (2007) * Based on data from: * Bland JM and Altman DG. (1986).Statistical methods for assessing agreement between two methods of clinical measurement, Lancet, February, pp 307-10. *; *==================================================IMPORTANT -- HARD CODED VALUES; * AXIS LIMITS FOR GRAPHS; * YAXIS (Vertical) is New Method- LARGE * XAXIS (Horizontal) is OLD Method - MINI; %let miny=-100;%let maxy=100;%let ticky=20; %let minx=100;%let maxx=700;%let tickx=50; *==================================================IMPORTANT -- HARD CODED VALUES; DATA BA; input large mini; diff=large-mini; avg=(large+mini)/2; datalines; 494 512 395 430 516 520 434 428 476 500 557 600 413 364 442 380 650 658 433 445 417 432 656 626 267 260 478 477 178 259 423 350 427 451 ; run; *...............................BLAND ALTMAN PLOTS * find the mean difference; data prelim;set ba; proc means noprint data=prelim;var diff; output out=diff mean=meandiff std=stddiff; run; data PERF;set prelim; if _N_=1 then set diff; ubound=meandiff+stddiff*2; lbound=meandiff-stddiff*2; label diff= 'Large-Mini' avg= '(large+mini/2)'; drop _type_ _freq_; run; title 'Bland-Altman Analysis'; *----------------NOTE FOR PLOTS---------------------- * Axis limits are specified in LET statment above. * ---------------------------------------------------; * Produce a scatterplot with a 45 degree line of reference (THE PLOT OF IDENTITY); data anno; function='move'; xsys='1'; ysys='1'; x=0; y=0; output; function='draw'; xsys='1'; ysys='1'; color='red'; x=100; y=100; size=2; output; run; symbol1 i=none v=dot c=black height=1; * X AXIS - HORIZONTAL; axis1 length=6.5 in width=1 value=(font="Arial" h=1) order=&minx to &maxx by &tickx; * YAXIS - VERTICAL; axis2 length=4.5 in width=1 value=(font="Arial" h=1) order=&minx to &maxx by &tickx; footnote ; proc gplot data=PERF; plot large*mini / anno=anno haxis=axis1 vaxis=axis2; run; quit; * -----------------------Create annotations for the Bland Altman Plot; data b;set diff; Maxaxis=&maxy; meanline=50+(meandiff/(maxaxis*2))*100; upper = 50+((meandiff+2*stddiff)/(maxaxis*2))*100; up=(meandiff+2*stddiff); lower = 50+((meandiff-2*stddiff)/(maxaxis*2))*100; length color function $8 text $14; retain xsys '1' ysys '2' when 'a'; /* The lines are positioned using the percentage of the horizontal axis,*/ * --this is the mean value for the y axis; function='move'; xsys='1'; ysys='1';x=0; y=meanline; output; function='draw'; xsys='1'; ysys='1';x=100; y=meanline; color='red'; size=2; output; * Upper confidence limit ------------- ; function='move'; xsys='1'; ysys='1'; x=0; y=upper; output; function='draw'; xsys='1'; ysys='1'; color='green'; x=100; y=upper; size=1; output; * Lower confidence limit ------------- ; *data Lower; function='move'; xsys='1'; ysys='1'; x=0; y=lower; output; function='draw'; xsys='1'; ysys='1'; color='green'; x=100; y=lower; size=1; output; run; *-------------- *-------------- CREATE THE BLAND ALTMAN PLOT *--------------; symbol1 i=none v=dot c=black height=1; * XAXIS - HORIZONTAL - AVERAGE; axis1 length=6.5 in width=1 OFFSET=(0,0) label=(f="Arial" h=2 'Average') value=(font="Arial" h=1) order=&minx to &maxx by &tickx; * YAXIS - Vertical - Difference; axis2 length=4.5 in width=1 OFFSET=(0,0) label=(f="Arial" h=2 'Difference') value=(font="Arial" h=1) order=&miny to &maxy by &ticky; footnote h=2 f="Arial" 'Bland-Altman Plot'; title h=2 f="Arial" 'Example'; proc gplot data=PERF; plot diff*avg/ anno=b haxis=axis1 vaxis=axis2; run; quit;