/****************************************************************************** * Programme : Sans titre * Reference : SANSTI6CEB * Source : https://www.wearecas.eu/en/sampleCode/SANSTI6CEB ******************************************************************************/ /* --- BLOC 1 --- */ data cash; input School Money; /* School = 0 = SMU School = 1 = Seattle U */ datalines; 0 34 0 1200 0 23 0 50 0 60 0 50 0 0 0 0 0 30 0 89 0 0 0 300 0 400 0 20 0 10 0 0 1 20 1 10 1 5 1 0 1 30 1 50 1 0 1 100 1 110 1 0 1 40 1 10 1 3 1 0 ; /* --- BLOC 2 --- */ proc ttest data=cash; class School; *may need to convert School to numeric; var Money; run; /* --- BLOC 3 --- */ ods output off; ods exclude all; *borrowed code from internet ... randomizes observations and creates a matrix ... one row per randomization ; proc iml ; use cash; read all var{School Money} into x; *change varibale names here ... make sure it is class then var ... in that order.; p=t(ranperm(x[, 2], 1000)); *Note that the "1000" here is the number of permutations. ; paf=x[, 1]||p; create newds from paf; append from paf; quit; *calculates differences and creates a histogram; ods output conflimits=diff; /* --- BLOC 4 --- */ proc ttest data=newds plots=none; class col1; var col2 - col1001; run; ods output on; ods exclude none; /* --- BLOC 5 --- */ proc univariate data=diff; where method="Pooled"; var mean; histogram mean; run; /* --- BLOC 6 --- */ data numdiffs; set diff; where method="Pooled"; if abs(mean) >=114.6; *if abs(mean) >=44.0667; *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 7 --- */ proc print data=numdiffs; where method="Pooled"; run;