/* STAT 541 HW 6 Solution, Spring 2021 */ /* Problem 1(a) */ Proc means mean data=sashelp.baseball; VAR nhome; run; /* Population mean = 11.10 */ /* Problem 1(b) */ data first50oddrecord; do obsnum=1 to 99 by 2; set sashelp.baseball point=obsnum; output; end; stop; run; proc means MEAN data=first50oddrecord; VAR nHome; run; /* Mean of first 50 odd = 12.56 */ /* Problem 1(c) */ data first50evenrecord; do obsnum=2 to 100 by 2; set sashelp.baseball point=obsnum; output; end; stop; run; proc means MEAN data=first50evenrecord; VAR nHome; run; /* Mean of first 50 even = 9.68 */ /* Problem 1(d) */ *sample with replacement; %macro sample50wr; data subsetwr (drop=i sampsize); sampsize=50; obsleft=totobs; do i=1 to sampsize; obsnum=ceil(ranuni(0)*totobs); set sashelp.baseball point=obsnum nobs=totobs; output; end; stop; run; proc means mean data=subsetwr; VAR nhome; run; %mend; /* Problem 1(e) */ %sample50wr; %sample50wr; %sample50wr; %sample50wr; %sample50wr; %sample50wr; %sample50wr; %sample50wr; %sample50wr; %sample50wr; /* Answers will vary */ /* Problem 1(f) */ *sample without replacement; %macro sample50wor; data subsetwor (drop=obsleft samplesize); samplesize=50; obsleft=totobs; do while (samplesize>0); obsnum+1; if ranuni(0)0; run; proc print data=matches; run; *part d; proc print data=matches; where countmatch>1; run;