zespri 发表于 2010-2-12 08:57
8# bobguy
感谢bobguy, 但surveyselect有一个问题, 就是如果要求取样数大于实际数, 就会报错.
****random generate samoe data;
data pop;
n0=1;
do g='1','2','3','4','5';
n=n0+ceil(ranuni(12345)*60);
do id=n0 to n;
other_var= ranuni(12345);
output;
end;
n0=n+1;
end;
keep id g other_var;
run;
proc freq data=pop;
table g/out=n;
run;
***build sampling rule here***;
data n2;
length size $200;
retain size ;
set n end=end;
if count>=10 then n=ceil(0.3*count) ;
else n=count ;
size=catx(' ', size, n);
if end then call symputx( 'size', size);
run;
proc surveyselect data=pop
method=srs n=(&size) /*** sanmple size for each group/strata ***/
seed=33091 out=Sample;
strata g;
run;
proc print; run;


雷达卡
京公网安备 11010802022788号







