Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: two loops of forval

From   "Ronnie Babigumira" <>
To   <>
Subject   st: two loops of forval
Date   Wed, 23 Feb 2005 12:18:47 +0100

Dear all
Im having a little trouble with forval. I would like to

1. Use a master data set
2. Keep observations that fall within a given range of a variable of
values and save that as a data set
3. Draw a sample from this smaller data set and then do a few more
4. Change the range in 2
5. Repeat 3

here is a really short version of what I have written

forval i = 5000(5000)20000 {
	forval j = 5(5)15 {
		u masterdata, clear
		keep if dfor < `i'
		save buffer_`i', replace
		local expl_vbls "bla bla bla"
		//some more stuff

		u buffer_`i', clear
		spatsam, g(`j') x(x) y(y) norest saving(b`i'_space`j')
replace //draw a subsample
		logit def `expl_vbls'

		//some more stuff

Im not sure this is doing what I want it to do. Essentially I would
like to implement the first loop

keep if dfor<`i'< 5000

and then on this portion of the data
implement the second loop forval j = 5(5)15

and then go back to the outer loop and increase the value of `i' and go
over this again.

Kindly advise on how I can proceed with this

*   For searches and help try:

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