previal 发表于 2010-5-30 11:02 
用SAS可以产生这样的随机数吗?比如产生只包括0 ,5 和10 的100个数,其概率分别为0.7,0.2和0.1
Yes!. Here is a brief explanation from online help.
The RANTBL function returns a variate that is generated from the probability mass function defined by p1 through pn . An inverse transform method applied to a RANUNI uniform variate is used.
A sample program attached below,
data t1;
seed=99612;
n=10000;
p1=0.7;p2=0.2;p3=0.1;
array a{3} _temporary_ (0,5,10) ;
do i = 1 to n;
x=a{rantbl(seed,of p1-p3)};
output;
end;
keep x;
run;
proc freq data=t1;
table x;
run;