/****************************************************************************** * Programme : Prueba de permutación para la comparación de medias * Reference : PRUEBADEA1 * Source : https://www.wearecas.eu/en/sampleCode/PRUEBADEA1 ******************************************************************************/ /* --- BLOC 1 --- */ data trauma; input state $ kcal; datalines; 0 19 0 20 0 20 0 21 0 21 0 21 1 22 0 23 0 23 1 23 1 25 1 26 1 30 1 38 1 39 ; /* 0 = Non-Trauma, 1 = Trauma */ /* --- BLOC 2 --- */ proc ttest data=trauma; class state; *may need to convert School to numeric; var kcal; run; /* --- BLOC 3 --- */ ods output off; ods exclude all; /* --- BLOC 4 --- */ proc iml ; use trauma; read all var{state kcal} into x; *change varibale names here ... make sure it is class then var ... in that order.; p=t(ranperm(x[, 2], 5000)); *Note that the "1000" here is the number of permutations. ; paf=x[, 1]||p; create newds from paf; append from paf; quit; /* --- BLOC 5 --- */ ods output conflimits=diff; /* --- BLOC 6 --- */ proc ttest data=newds plots=none; class col1; var col2 - col1001; run; /* --- BLOC 7 --- */ ods output on; ods exclude none; /* --- BLOC 8 --- */ proc univariate data=diff; where method="Pooled"; var mean; histogram mean; run; /* --- BLOC 9 --- */ data numdiffs; set diff; where method="Pooled"; if abs(mean) >=7.8089; *you will need to put the observed difference you got from t test above here. note if you have a one or two tailed test.; run; /* --- BLOC 10 --- */ proc print data=numdiffs; where method="Pooled"; run;