Announcement

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

  • Randomly cutting observations from dataset

    I am using a dataset with over 60,000,000 observations -- how can I randomly cut observations to roughly 1/4 of this amount? Is there a relatively straightforward STATA command for this?

  • #2
    drop if r(uniform) < 0.75

    Comment


    • #3
      As an addition to George's helpful response: if you want to make this process reproducible (which you probably should), you can extend the command to:
      Code:
      set seed 123
      drop if r(uniform) < 0.75
      Best wishes

      Stata 18.0 MP | ORCID | Google Scholar

      Comment


      • #4
        The random number function is -runiform()-

        Code:
        help runiform()

        Comment

        Working...
        X