Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Random sampling

    Hello, I have a dataset of 102 nurseries, I want to randomly sample 16 out of them. I tried the sample and bsample codes but they are not functioning properly. whenever I run them I get 3, 1, or even no nurseries at all. I don't understand what's wrong.
    Would greatly appreciate your insight.

  • #2
    If an observation is a nursery in the dataset, you can just use the -rnormal()- function to select the sample.

    Code:
    gen selector= rnormal()
    sort selector
    gen sample=_n<=16
    list if sample

    Comment


    • #3
      Thank you for your help. I tried running and I still have the same issue, only 4 or 5 nurseries appear. Noting that my dataset is composed of 4 variables, they are all strings.
      The variables are basically : Nursery Name, NGO, Manager, Mobile number.
      I want to draw the sample for the nursery name but for some reason it keeps on producing missing randoms.

      Comment


      • #4
        I cannot follow this. Can you copy and paste the exact command that you typed and the Stata output that shows what you state? If you can share the data, present a sample of the dataset using the dataex command.

        Code:
        dataex

        Comment


        • #5
          I figured out what was wrong, turned out there about 800 missing observations that's why the code wasn't functioning properly.
          Thank you for your help!

          Comment

          Working...
          X