jingju11 发表于 2012-12-21 13:25 
这个程序只是实现最简单的随机条件性选择。程序没有测试。在R编辑器里书写,在sas运行是改变#符号
京剧
T ...
There is a exist procedure, namely proc surveyselect that can deal with stratify sampling.
Here is an example,
data t1;
do id=1 to 9100;
x=ranuni(123);
flag=0;
if x<0.5 and cnt<=99 then do;
flag=1;
output;
cnt+1;
end;
else output;
end;
run;
proc freq data=t1;
table flag;
run;
proc sort data=t1;
by flag;
run;
proc surveyselect data=t1 n=(150 50)
seed=4321 out=Sample;
strata flag;
run;
proc freq data=Sample;
table flag;
run;