Statalist The Stata Listserver


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

st: Re: sampling problem


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   st: Re: sampling problem
Date   Tue, 19 Jun 2007 11:21:53 -0400

...
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]>
To: <[email protected]>
Sent: Tuesday, June 19, 2007 10:50 AM
Subject: st: sampling problem



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)

What I want to do is to create a program which will run this command several times. The problem is that I want the ncases(integer) to be different. I have a vector of values which I want ncases to take on. So I run I may have 5 different values in my vector. I want to run samplepps five times with ncases taking on the value of the first row of the vector for the first time, the second row the second time and so on.

Is there any quick way of doing this or do I just have to manually enter the number each time?

Thank you,
John

<snip>

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