proc iml; f={75000, 225000, 75000, 147764, 375000, 150000, 150000, 92490, 34521, 80015, 82771, 125000, 285845, 125000, 219243, 66842, 125000, 225000, 172356}; /* Create variables that specify the number of iterations and the vector that holds the number of successes */ iter = 10000; success = j(iter,1,0); /* Specify module that will sample with replacement */ start samplereplace(A, nSamples); results = j(nSamples,1); /** allocate result matrix **/ call randgen(results, "Uniform"); /** fill with random U(0,1) **/ if ncol(A)>nrow(A) then n=ncol(A); else n=nrow(A); results = ceil(n*results); /** convert to integers 1,2,...n **/ return(shape(A[results], nSamples)); /** reshape and return from A **/ finish; /* Perform simulation; every time the alternative hypothesis is met, set a 1 for the iteration number */ do i=1 to iter; s = samplereplace(f,19); m_s = mean(s); if m_s < 135000 then success[i,] = 1; end; /* Calculate and display the p-value */ pvalue = 1 - mean(success); print pvalue; quit;