Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Sampling question

From   Steve Samuels <>
Subject   Re: st: Sampling question
Date   Sun, 25 Nov 2012 16:33:36 -0600


I suggest that you use  Ben Jann's -gsample- command, from SSC.

The following example draws 15 observations from one category of "foreign" 
in the auto data set, and 5 in the other. Adapt to your own needs. You need
the -preserve- and -restore- commands, because -gsample- keeps only the
sampled observations.


sysuse auto, clear
gsample 10 if rep78==3, wor
tempfile t3
save `t3', replace

gsample 5 if rep78==4, wor
tempfile t4
save `t4', replace

gsample 3 if rep78==5, wor
append using `t3'
append using `t4'

tab rep78
save autosamp, replace

On Nov 25, 2012, at 3:51 PM, Wendy Alfaro wrote:

Dear Steve:

The answer is b.

Thank you in advance,


On Sun, Nov 25, 2012 at 3:27 PM, Steve Samuels <> wrote:

Wendy Alfaro Chaves
Consultora e investigadora
Agricultura, ambiente y alimentos
T: (506) 2494-3647
Skype: wendy07
*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index