Sunday, February 21, 2010

PROC SURVEYSELECT

Simple random sample without replacement
Select a random sample where no observation can be chosen more than once.

/* WORK.EASTHIGH is a data base of student grade point averages */
/* from East High School, Grades 9 through 12, 100 or more students per grade. */

data EastHigh;
      format GPA 3.1;
      do Grade=9 to 12;
            do StudentID=1 to 100+int(201*ranuni(432098));
                  GPA=2.0 + (2.1*ranuni(34280));
                  output;
            end;
      end;
run;

/* Using PROC SURVEYSELECT */
/* Use METHOD=SRS. N= is the number of observations to select. */
/* The sample is stored in the OUT= data set, SAMPLE1. */

proc surveyselect data=EastHigh method=srs n=15 out=sample1;
run;

title "PROC SURVEYSELECT";
proc print data=sample1;
run;


Simple random sample with replacement
Select a random sample where an observation can be chosen more than once.

/* Using PROC SURVEYSELECT */
/* Use METHOD=URS. N= is the number of observations to select. */
/* The sample is stored in the OUT= data set, SAMPLE. */
/* The OUTHITS option includes an observation in the OUT= data set */
/* for each selected unit. By default, the OUT= will contain one */
/* observation for each unique selected unit and the NumberHits */
/* variable identifies the number of times each unit is selected. */

proc surveyselect data=EastHigh method=urs n=15 out=sample outhits;
run;

title "PROC SURVEYSELECT ";
proc print;
run;

No comments: