dimanche 1 avril 2018

SAS Random Sampling

In SAS I have created a program that will randomly take 50 observations from a data set and calculate a mean value for the observations.

data subset (drop=i samplesize);
samplesize=50;
obsleft=totobs;
do i=1 to samplesize;
  obsnum=ceil(ranuni(0)*totobs);
  set sashelp.baseball point=obsnum nobs=totobs;
  output;
end;
stop;
run;


proc sql;
select mean(nHome) from subset;
quit;

I would like to edit the code so it will produce 10 independent random samples instead of one (I am aware of the reps= in Proc SurverySelect, but I am not supposed to use it here). Thanks




Aucun commentaire:

Enregistrer un commentaire