Announcement

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

  • Select a subsample from a database

    Hi, I have a database with 5000 obs of which I only need 600. I have used the following syntax:

    set seed 10101
    sample 600 if valid == 1, count (valid is a conditional variable for the selection)

    However, running 'sample' removes all other observations. I want to create a variable that puts 1 to the selected observations and 0 to the unselected ones, instead of deleting them.

    Any advice for it?

    Thank you,
    Adolfo Aramburu

  • #2
    The randomselect command might be what you're looking for. You can install it using
    Code:
    ssc install randomselect
    Then, you can generate the dummy sample variable using this command:
    Code:
    randomselect if valid == 1, gen(sample) n(600)

    Comment


    • #3
      It worked perfect, thanks

      Comment

      Working...
      X