Statalist The Stata Listserver


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

st: looping over observations


From   "emre ekinci" <eekinci2610@hotmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: looping over observations
Date   Wed, 14 Mar 2007 13:23:05 +0000

I have 100 observations.

I want to execute some commands for each observation.here is the basic structure:

local i=0

while `i'<=100 {
local ++i

if ((husbage1>husbage2) | (husbage11 <husbage2)) {

stata commands
}

else {
stata commands
}

}

if the logical statment is true for the first observation, it executes all commands within the if statement for other observations as well, although the logical statement is false for some observations.
what is my mistake here? How can I write a loop that executes some bunch of commands (including if else statement)?

thank you.

_________________________________________________________________
En etkili ve güvenilir PC Korumayi tercih edin, rahat edin! http://www.msn.com.tr/security/

*
* 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index