BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
desireatem
Pyrite | Level 9

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
1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Add option OUTHITS to the Proc Surveyselect statement. - PG

PG

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

Add option OUTHITS to the Proc Surveyselect statement. - PG

PG

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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