Statalist The Stata Listserver


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

st: Re: Macro syntax help


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   st: Re: Macro syntax help
Date   Sun, 05 Feb 2006 12:59:20 -0500

I'm not sure where the problem is, but I have some suggestions. First, you don't need to create the indic and blah variables since regress returns the number of observations in e(N) and, even if it didn't, you could just use a count command and r(N). It also isn't clear why you issue the same regress command twice and place the same result into two different variables.

Michael Blasnik


----- Original Message ----- "Meryle Weinstein" <[email protected]> wrote:

I'm using the following syntax to run a regression analysis on a
subset of cases that fall within a range of values (above/below the
cutoff).  For some reason it's running the analysis on a random
selection of cases that fall all over the place -- some are within the
range, while others are way out of the range.  Any help in finding a
bug in the program is appreciated.

Meryle Weinstein
Research Scientist
Institute for Education and Social Policy
New York University

gen below = .
gen above = .
gen observ = .
gen window = .

gen treatfx_m4_2 = .
gen se_m4_2 = .
gen diff_m4_2 = .

local counter = 0

forvalues temp=0.25(0.05)10 {
replace below = cutoff - `temp'
replace above = cutoff + `temp'

local counter = `counter' + 1

regress p34mg4 ppov bor1t1 if ppov > below & ppov < above
replace diff_m4_2 = _b[bor1t1] in `counter'

regress p34mg4 ppov bor1t1 if ppov > below & ppov < above
replace treatfx_m4_2  = _b[bor1t1] in `counter'
replace se_m4_2 = _se[bor1t1] in `counter'
gen indic = 1 if ppov > below & ppov < above
egen blah = sum(indic)
replace observ = blah in `counter'

drop blah indic

replace window = `temp' in `counter'
}
*
*   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