doudoupigfish 发表于 2010-5-14 10:10
因为要研究缺失数据的一些问题,想要先通过模拟完整数据集,然后在此基础上构建不同缺失率(如缺失10%,30%,50%等)的随机数据集,不知道该如何用SAS 实现,还请高手相助, 非常感谢!
Here is an example of random sample w/o replacement.
The METHOD=SRS option specifies simple random sampling as the sample selection method. In simple random sampling, each unit has an equal probability of selection, and sampling is without replacement.
data t1;
do i = 1 to 100;
x=rannor(123);
x2=x+0.001*rannor(123);
err= rannor(123);
y=1+ x+x2 ;
output;
end;
run;
***if you know the sample size in numbers***;
proc surveyselect data=t1 seed=778
method=srs n=80 out=t2;
run;
***if you know the proportion***;
proc surveyselect data=t1 seed=778
method=srs rate=0.8 out=t3;
run;