Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Re: sampling problem


From   Steven Samuels <[email protected]>
To   [email protected]
Subject   Re: st: Re: sampling problem
Date   Tue, 19 Jun 2007 11:38:55 -0400

I would only add to Michael's excellent advice: set an explicit seed. If you do not, the next time your run your program file, the samples will be different.

-Steven

set seed 89018666

local vals "100 240 300 350 412"
foreach val of local vals {
  samplepps sample`val', ncases(`val')
On Jun 19, 2007, at 11:21 AM, Michael Blasnik wrote:

...
I'm not sure what else you may want to do between calls to samplepps, but it seems like you may want to use a forvalues or foreach loop. If you just want to create 5 new variables resulting from repeated calls to samplepps, then something like this may work:

local vals "100 240 300 350 412"
foreach val of local vals {
samplepps sample`val', ncases(`val')
}

of course, you would need to add in any other options you want to the samplepps command and you may want to name the new variables differently, which you could do by creating a counter in the loop.

By the way, you shouldn't include an old message in your posting -- please follow the faq.

Michael Blasnik

----- Original Message ----- From: "John allfish" <[email protected]>



I have been trying a number of ways of sampling. I want to use the samplepps command which has the following syntax:

samplepps newvar, withrepl size(varname) ncases(integer)

*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index