Hello everyone,
I've run into a problem trying to randomly sample a part of my dataset (to make up a control group for econometric analysis). I'm trying to randomly sample 63 schools from, let's say a total of 500. I can easily set the seed and get that sample but the problem is that each school has 11 observations to its name, one for each year of data. Ideally I would like to keep all eleven observations for each of the 63 randomly selected schools, giving me 693 observations at the end of the day, but I haven't been able to figure out a command to do so. I've read up on sample2 and bsample but they each seem to focus on individual observations. Is there an option for either of those commands that I'm overlooking that will do the trick?
For those who work better with visuals, here is a table with three schools, multiple observations each. Let's say I'd like to randomly sample two out of the three schools but keep the rest of their observations. How might I do this?
Thanks,
Thomas
Stata Version: 13
I've run into a problem trying to randomly sample a part of my dataset (to make up a control group for econometric analysis). I'm trying to randomly sample 63 schools from, let's say a total of 500. I can easily set the seed and get that sample but the problem is that each school has 11 observations to its name, one for each year of data. Ideally I would like to keep all eleven observations for each of the 63 randomly selected schools, giving me 693 observations at the end of the day, but I haven't been able to figure out a command to do so. I've read up on sample2 and bsample but they each seem to focus on individual observations. Is there an option for either of those commands that I'm overlooking that will do the trick?
For those who work better with visuals, here is a table with three schools, multiple observations each. Let's say I'd like to randomly sample two out of the three schools but keep the rest of their observations. How might I do this?
Observation | School | Year |
1 | A | 1995 |
2 | A | 1996 |
3 | A | 1997 |
4 | A | 1998 |
5 | B | 1995 |
6 | B | 1996 |
7 | B | 1997 |
8 | B | 1998 |
9 | C | 1995 |
10 | C | 1996 |
11 | C | 1997 |
12 | C | 1998 |
Thanks,
Thomas
Stata Version: 13
Comment