Statalist


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

st: loop problem with missing data


From   [email protected]
To   [email protected]
Subject   st: loop problem with missing data
Date   Wed, 09 Jul 2008 23:27:36 -0500

I have a panel dataset with countries and years. I am trying to do some overlapping  regressions for every country in windows of 5 years. I want these 5 years to be overlapping so for example for United States, I want the first regression to be for 1980-1984, the second 1981-1985, third 1982-1986 and goes on like this. I have used loop within a loop to do this. As you can see from the do file below

i stands for countries and j stands for years


local i=1

while `i'<131 {

local j=1980

while `j'< 2006 {

reg y  x1 x2 x3  if cc==`i' & (year==`j'|year ==`j'+1|year ==`j'+2|year==`j'+3|year ==`j'+4)

local j= `j'+1

}

local i= `i'+1

}

However I have missing data for some countries and years, so when the loop starts if it does not find any data for the first country and/or first group of years the do file stops.

I have tried to use capture command, but still was unable to make the loop work.
Could someone help me out here, how should I do these regressions.
I'd really appreciate any help .

 

Indrit Hoxha

Univesity of Houston





Indrit Hoxha
PhD Candidate
University of Houston, Department of Economics
204 McElhinney Hall, Houston , TX 77204
Tel 713-743-3817, Fax 713-743-3798
Web: www.uh.edu/~ihoxha





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