Announcement

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

  • Random sampling in a data set

    Hi all,

    I have a data set that has many variables concerning civil war. One of the variables is called "warname" and I want to use stata to randomly sample 4 of these wars for the purpose of my work. How would I go about doing this and perhaps put these 4 selected observations in a new variable?

    Any help will be much appreciated!

  • #2
    Hi Finn,

    I am not entirely clear on your question, but the Stata command sample will allow you to perform random sampling of your observations, without replacement.

    If you want one observation from each war, you could try something like...

    sample 1 , count by(warname)
    This command will not create new variables, though I'm not sure how that would look and what the value would be, but will remove all other observations that aren't sampled.

    Comment


    • #3
      Originally posted by Matt Warkentin View Post
      Hi Finn,

      I am not entirely clear on your question, but the Stata command sample will allow you to perform random sampling of your observations, without replacement.

      If you want one observation from each war, you could try something like...



      This command will not create new variables, though I'm not sure how that would look and what the value would be, but will remove all other observations that aren't sampled.
      Thanks Matt, had to play around with the commands a bit but worked it out!

      Comment

      Working...
      X