# Re: st: Sampling scheme

 From SamL To statalist@hsphsun2.harvard.edu Subject Re: st: Sampling scheme Date Thu, 12 Jul 2007 16:14:01 -0700 (PDT)

```Yes.  I would proceed as follows:

gen group=yourvariable
recode group (11/13=1) (21/23=2) (31/33=3)
sort group            <---not sure this is needed
set seed *******      <---pick a number, so you can reproduce results
by group: sample 25, count

makes it give you a sample of 25 units for each group, without count it
will sample 25% of each group.

I think this'll work to give you the samples you need.

Hope this helps.
Sam

On Thu, 12 Jul 2007 tiago.pereira@incor.usp.br wrote:

> Dear statalisters,
>
> I have a variable in which observations take one out of 9 values:
> 11,12,13,21,22,23,24,31,32,33
>
> So, observations assume the values 1`i', 1`i', 3`i', for i = 1,2 or 3.
>
> Assuming that I have 1000 observations , I would like to:
>
> (1) randomly sample, say, 25 observations satisfying the condition ==1`i'
>
> (2) randomly sample 50 observations satisfying the condition ==2`i'
>
> (3) randomly samply another 25 observations satisfying the condition ==3`i'
>
> Then, I would like to count the frequency of each `i' in the first, second
> and last samplings.
>
> For example, considering yet the example above, assume that among the
> first sampling (25 obs), 12 observations were 1`3', 10 were 1`1' and 3
> were 1`2' (12+10+3 = 25 sampled observations).
>
> I would like to obtain the following result:
>
> `1' = 10
> `2' = 03
> `3' = 12
>
>
> Is it possible to perfom such sampling scheme using Stata?
>
> Thank you very much.
>
> Tiago
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```