Announcement

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

  • taking a random sample

    Hi i would like to take a random sample from my dataset, however I have
    gender === 1 ///male 200,000 observations
    gender == 0 ///female 5,000 observations

    Is there a way that if I take a random sample I would have fair representation of male & female ?
    what I don't want is stata to remove all the females for eg

    Code:
    sample 20,500

  • #2
    Seems like you want the by option.

    Code:
    sample 20, by(gender)
    I'm not sure what 500 is doing there, but it doesn't appear to be valid syntax.

    Edit: there are a lot of ways to take a random sample. That will stratify by gender. Let us know if you want something else - e.g. sampling with a probability weighted by gender.
    Last edited by Daniel Schaefer; 09 Feb 2024, 15:37.

    Comment

    Working...
    X