1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
%macro tasr(libref=,entree=,sortie=,nb=);
data &libref..&sortie (drop=i j count);
count=0;
array obsnum(&nb) _temporary_;
do i=1 to &nb;
redo:
select=ceil(ranuni(12345)*n);
set &libref..&entree point=select nobs=n;
do j=1 to count;
if obsnum(j)=select then goto redo;
end;
position=select;
count=count+1;
obsnum(count)=select;
output;
end;
stop;
set &libref..&entree;
run;
%mend;
Exemple :
Tirage au sort de 300 observations dans une table de 500 observations
data donnees (drop=var);
do var=1 to 500;
x=round(ranuni(1251)*100);
output;
end;
run;
%tasr(libref=work,entree=donnees,sortie=donnees2,nb=300); |
Partager