*
; /* Date: Tue, 18 Oct 1994 10:26:44 GMT Sender: "SAS(r) Discussion" From: Alain Duhamel;Organization: Universite des Sciences et Technologie de LILLE, France Subject: Macro in SAS Langage to compute the Kappa's Statistic To: Multiple recipients of list SAS-L */ /*************************************************************************** This macro command in SAS language has been written to calculate the Kappa's statistic. We assume that : - lign is the name of the lign in the contingency table - col is the name of the column in the contingency table - tab is the name of the dataset OUTPUT : Kappa's statistic,standard deviation of the kappa, Epsi=Ka/SD(Ka) (=N(0,1)) and Prob( >Epsi) ***************************************************************************/ /*--------------------------------------------------------------------------- I Alain DUHAMEL I I Centre d'Etude et de Recherche en Informatique Medicale I I Universite de LILLE2 I I LILLE-FRANCE I I DUHAMEL@CORTEX.DECNET.CITILILLE.FR I ---------------------------------------------------------------------------*/ %macro kappa(lign,col,tab); proc freq data=&tab; /* Print of the contingency table*/ tables &lign*&col/nocol norow nopercent expected exact; proc contents data=&tab noprint out=nobs; data _NULL_; set nobs; if _N_ gt 1 then delete; /*Research of N=number of observations*/ keep nobs; call symput('nbrobs',left(nobs)); proc datasets; delete nobs; proc corresp data=&tab noprint outf=corresp; tables &lign,&col; data corresp; set corresp; if &lign=&col; data observed; /* Sum of the OBSERVED to calculate P0 */ set corresp; if _type_="OBSERVED"; proc means noprint; var count; output out=means sum=; data _NULL_; set means; call symput('SOMOBS',left(count)); proc datasets; delete means; data expected; /* Sum of the EXPECTED to calculate Pc */ set corresp; if _type_="EXPECTED"; proc means noprint; var count; output out=means sum=; data _NULL_; set means; call symput('SOMEXP',left(count)); proc datasets; delete corresp observed expected means; data res; /* Computing of Kappa, DS, EPSI and PROB*/ p0=&somobs; n=&nbrobs;p0=p0/N; pc=&somexp;pc=pc/n; kappa=(P0-pc)/(1-pc); dskappa=sqrt(pc/(n*(1-pc))); epsi=kappa/dskappa; p=2*(1-probnorm(epsi)); proc print; /* Printing of the results*/ title2 "Kappa pour le tableau &&lign * &&col"; title3 "P0=% de bien classes ; PC= % hasard"; title5 " CONDITIONS DE VALIDITE"; title7 "Ciccheti: n> 2*(k)**2 (k=nbr modal)"; title8 "Fermanian: n>25 si k=3; n>30 si k=4 ou 5"; %mend kappa; *