That is hard.
It is almost impossible to consider the entire factors simultaneously in the model. You may want to simplify your model for a justified simulation.
虽然产生随机数有很多种方法,但不过我想不论是简是繁大概大都需要从最基本的套订公式开始,也就是:
1。选定一个你所需要的随机数从哪一种分布来获得:通常有:ranbin, rancau, ranuni或rand等等。
2。然后,你可以选定带有种子的(ranbin, rancau, ranuni),或不带种子的(rand('UNIFORM‘))SAS语句。
3。然后,你可以选定可控范围内(rn3=1+int(rand('UNIFORM')*90);*range: 1-90;)或非控范围内(randnum=rand('UNIFORM'))取值。
4。最后,可以根据你想要的简繁程度和具体的需要,选定写出一个或多个或混合的随机数公式去控制一个变量或多个变量。
5。最后,察看你的随机数字的结果是否符合你的需要。
下面是几个简短的公式应用范例,根据你具体个人的需要可以加以修改!
data case;
retain Seed_1 Seed_2 Seed_3 45;
n=2000;
p=.2;
do i=1 to 10;
call ranbin(Seed_1,n,p,X1);
call ranbin(Seed_2,n,p,X2);
X3=ranbin(Seed_3,n,p);
if i=5 then
do;
Seed_2=18;
Seed_3=18;
end;
output;
end;
run;
DATA DICE(KEEP=SUM) OUTCOMES(KEEP=OUTCOME);
DO ROLL=1 TO 10000; *** roll the two dice 10,000 times.;
OUTCOME1=1+INT(6*RANUNI(123)); *** outcome from rolling the first dice;
OUTCOME2=1+INT(6*RANUNI(123)); *** outcome from rolling the second dice;
SUM=OUTCOME1+OUTCOME2; *** sum up the two outcomes.;
OUTPUT DICE; *** save the sum.;
OUTCOME=OUTCOME1; OUTPUT OUTCOMES; *** save the first outcome.;
OUTCOME=OUTCOME2; OUTPUT OUTCOMES; *** save the second outcome.;
END;
RUN;