There is an -egen- function -record()- in
-egenmore- from SSC to do this.
Nick
[email protected]
[email protected]
> Do you mean something like this:
>
> sysuse auto,clear
> gen time = _n
> tsset fore time
> sort fore time
> gen max_mpg = mpg
> replace max = max(l.mpg, l.max ,max)
>
> or just:
>
> egen max2 = max(mpg), by(fore)
>
>
> Note: The expression "l0.x&l1.x&l3.x" is a logical operation that
> will return 1 if it is true - it will interpret any nonzero values as
> true and zero as false. See [U] 13 Functions and expressions.
Thomas <[email protected]>
> > I am trying to get the maximum of all past or present values, i.e.
> >
> > x[i] = max x[j, j<=i]
> >
> > I tried the following commands:
> >
> > bysort id (yr): egen x1 = max(l0.x&l1.x&l3.x), which returns 1
> > instead
> > of the max,
> > and
> > bysort id (yr): egen x1 = max(l(0/3).x), which produces an error.
*
* 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/