Simple random sampling with all observation record not just Hits number

Accepted Solution Solved
Reply
Super Contributor
Posts: 303
Accepted Solution

Simple random sampling with all observation record not just Hits number

Hello The simple random code with replacement usually produce output with hits number, for instant id 22 is chosen three times. However I do not want the output like that , I want all the three hit live in the second output. That I want the sample size to stay 10, even if it is not independent like in output two below.

proc surveyselect data = hsb25 method = SRS rep = 1

  sampsize = 10 seed = 12345 out = hsbs1;

  id _all_;

run;

proc print data = hsbs1 noobs;

run;

proc surveyselect data=hsb25  method = urs sampsize = 10
   rep=1 seed=12345 out=hsbs2 out=outhits;
   id id read write math science socst;
run;

proc print data = hsbs2 noobs;

run;

OUTPUT ONE

            Rep    id    re    wri   math    sc    soc     Hits

                  1        108     34       33      41        36        36        1

    1         50     50       59      42        53        61        1
    1        102     52       41      51        53        56        1
    1        136     65       59      70        63        51        1
    1        171     60       54      60        55        66        1
    1         22     42       39      39        56        46        3
    1         47     47       46      49        33        41        1
    1         56     55       45      46        58        51        1

Hello The code above gives the output of Simple random sampling with replacement.  The sample size is 10. However I am not happy with the way the data is reported. I want the Hits= 3 to be reported three times. I wish to ask if any knows how to help me report the data like this:

OUTPUT TWO
      Rep    id    re    wri   math    sc    soc     Hits
 
    1        108     34       33      41        36        36        1
    1         50     50       59      42        53        61        1
    1        102     52       41      51        53        56        1
    1        136     65       59      70        63        51        1
    1        171     60       54      60        55        66        1
    1         22     42       39      39        56        46        1
    1         22     42       39      39        56        46        1
    1         22     42       39      39        56        46        1
    1         47     47       46      49        33        41        1
    1         56     55       45      46        58        51        1

Accepted Solutions
Solution
‎10-31-2013 10:05 PM
Respected Advisor
Posts: 4,935

Re: Simple random sampling with all observation record not just Hits number

Posted in reply to desireatem

Add option OUTHITS to the Proc Surveyselect statement. - PG

PG

View solution in original post


All Replies
Solution
‎10-31-2013 10:05 PM
Respected Advisor
Posts: 4,935

Re: Simple random sampling with all observation record not just Hits number

Posted in reply to desireatem

Add option OUTHITS to the Proc Surveyselect statement. - PG

PG
Super Contributor
Posts: 303

Re: Simple random sampling with all observation record not just Hits number

Thanks PGStats

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 160 views
  • 0 likes
  • 2 in conversation