Nick,
Thanks - I over looked that.
But I think I misinterpreted the question. If only the last three time
periods are to be summed, then what I originally had is the last three
periods of the cumulative sum over the entire time span. Instead, I believe
this should work:
bysort id (t): gen foo = sum(abs((pip - l.pip)/l.pip)) if t > t[_N -3]
Scott
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
> Sent: Tuesday, November 07, 2006 5:09 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: RE: RE: summation (+ absolute value) formula
>
> In a panel, I guess the second -replace- should
> be -by id:- also. Otherwise _N has the interpretation
> of the number of observations in the dataset, not
> in each panel.
>
> Nick
*
* 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/