-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathASG2.sas
84 lines (84 loc) · 1.98 KB
/
ASG2.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
data random;
retain seed 2766;
do i = 1 to 10;
x = ranuni(seed);
output;
end;
proc print;
Run;
data rand10;
retain seed 2766;
do i = 1 to 10;
if ranuni(seed) < 0.10 then success=1;
else success=0;
output;
end;
proc univariate data = rand10;
var success;
TITLE1 ‘SUM=OBSERVED NUMBER OF SUCCESSES’;
TITLE2 ‘MEAN=OBSERVED PROPORTION OF SUCCESSES’;
run;
data random2;
retain seed1 2766;
retain seed2 5897;
do x=1 to 1000;
***repetitions;
r1=ranuni(seed1);
r2=ranuni(seed2);
***you must lock the random number by assigning it a value r1 or r2;
***otherwise each use of the function generates another number;
if r1<0.55 and r2<0.55
then females = 2;
else if r1>=0.55 and r2>=0.55
then females = 0;
else females=1;
output;
end;
proc univariate data=random2 freq;
var females;
proc gchart data=random2;
VBAR FEMALES / MIDPOINTS=0 1 2;
run;
data random2;
retain seed1 2654;
retain seed2 3369;
do x=1 to 1000;
***repetitions;
r1=ranuni(seed1);
r2=ranuni(seed2);
***you must lock the random number by assigning it a value r1 or r2;
***otherwise each use of the function generates another number;
if r1<0.55 and r2<0.55
then females = 2;
else if r1>=0.55 and r2>=0.55
then females = 0;
else females=1;
output;
end;
proc univariate data=random2 freq;
var females;
proc gchart data=random2;
VBAR FEMALES / MIDPOINTS=0 1 2;
run;
data randomnorm;
retain seed1 1104094;
Do Ns=4,16,64,100 /*Ns is the sample size*/;
do j=1 to 100 /*j is the number of
repeated samples (reps)*/;
do number=1 to Ns;
x1=rannor(seed1);
output;
end;
end;
end;
run;
proc univariate data=randomnorm noprint;
var x1 ;
by Ns j notsorted;
output out=summary mean=mean n=n std=sd;
run;
proc print data=summary;
proc means data=summary;
by Ns notsorted;
var mean;
run;