Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: historical maximum


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: historical maximum
Date   Mon, 26 Sep 2005 21:50:55 -0400

Michael suggested

You can get the running/cumulative maximum using subscripting, such as

gen cummax=x in 1
replace cummax=max(x,cummax[_n-1]) in 2/l

If you have panel data or missing data/gaps, you may want to check out using
time series operators by using tsset.


The egen function record (think of setting a record...) handles the nitty-gritty details quite nicely. It is available in the egenmore package from ssc. It will deal with panel data and missing values.


Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html


*
* 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