How about this:
while b == . {
	replace b=b[_n+1]*c if b==. & year <1999
	replace b=b[_n-1]*c if b==. & year >1999
}
Scott
----- Original Message -----
From: Dev Vencappa <[email protected]>
Date: Monday, July 12, 2004 10:19 am
Subject: Re: st: filling previous missing observations repeatedly.
> >>
> >>
> >>
> Stata users, I have the following data set
> 
> year           B           C          Country
> 1995          .            x           Belgium
> 1996          .            x           Belgium
> 1997          .            x           Belgium
> 1998          .            x           Belgium
> 1999          x           x           Belgium
> 2000          .            x           Belgium
> 2001          .            x           Belgium
> 2002          .            x           Belgium
> 
> Variable B has data for only 1999 and missing for other years. I 
> want to extrapolate missing years using variable C, which is some 
> kind of multiplicative scalar that varies over the years. Writing 
> a command like the following seems to work fine to fill missing 
> values after year 1999:
> 
> replace B=B[_n-1]*C if B==. & year>1999 & country=="Belgium"
> 
> However, the following does not seem to work (or at least fills 
> the missing value for the year 1998 only):
> 
> replace B=B[_n+1]*C if B==. & year<1999
> 
> I believe this is because Stata works only forward and not 
> backward. Is there a way to ask Stata to work backwards starting 
> with the value from the year 1999 and repeat the command for prior 
> years? I have tried the following loop command but that does not 
> seem to work either (this command does not even fill in the 
> missing value for the year 1998, for obvious reasons)
> 
> while B[_n+1]!=. & B==. & country=="Belgium"{
> replace B=B[_n+1]*C
> }
> 
> I think I am missing a syntax of Stata here.
> 
> Many thanks
> Dev
*
*   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/