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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Sampling question


From   Steve Samuels <sjsamuels@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Sampling question
Date   Sun, 25 Nov 2012 16:33:36 -0600

Wendy:

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.

Steve

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

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

restore
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,

Wendy

On Sun, Nov 25, 2012 at 3:27 PM, Steve Samuels <sjsamuels@gmail.com> wrote:



-- 
Wendy Alfaro Chaves
Consultora e investigadora
Agricultura, ambiente y alimentos
T: (506) 2494-3647
Correo-e: wendyalfaro07@gmail.com
Skype: wendy07
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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