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

st: Re: Is there a statacommand for a Historical Maximum? & How tocumulate series?


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: Is there a statacommand for a Historical Maximum? & How tocumulate series?
Date   Mon, 26 Sep 2005 08:05:17 -0400

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. You can get a cumulative sum using the sum function

gen cumsum=sum(x)

Michael Blasnik
michael.blasnik@verizon.net

*
* 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index