%let n1 =8; /* group sizes*/
%let n2 = 8;
%let NumSamples= 3000; /* number of simulated samples */
dataPowerSim(drop=i);
callstreaminit(321) ;
do Delta = 0 to2 by 0.1;
do SampleID = 1 to &NumSamples;
c = 1; /* Group 1 */
do i = 1 to &n1;
x = rand("Normal", 0,1); /* x ~ N(0,1) */
output;
end;
c = 2; /* Group 2 */
do i = 1 to &n2;
x = rand("Normal", Delta,1); /* x ~ N(Delta, 1) */
output;
end;
end;
end;
run;
/* 2. Compute(pooled) t test for each sample */
%ODSOff
proc ttest data=PowerSim;
by Delta SampleID;
class c;
var x;
ods outputttests=TTests(where=(method="Pooled"));
run;
%ODSOn
/* Constructindicator var for obs that reject H0 at 0.05 significance */
data Results;
set TTests;
RejectH0 = (Probt <= 0.05);
run;
/* 3. Computeproportion: (# that reject H0)/NumSamples and CI */
%ODSoff
proc freqdata=Results;
by Delta;
tables RejectH0 / nocum binomial(level='1');
output out=Est binomial;
run;
%ODSOn


雷达卡



京公网安备 11010802022788号







