Statalist The Stata Listserver


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

st: RE: RE: RE: summation (+ absolute value) formula


From   "Scott Merryman" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: summation (+ absolute value) formula
Date   Tue, 7 Nov 2006 17:23:15 -0600

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: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Nick Cox
> Sent: Tuesday, November 07, 2006 5:09 PM
> To: [email protected]
> 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/



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