Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# re:st: Finding Maximum of a series

 From Christopher Baum To "statalist@hsphsun2.harvard.edu" Subject re:st: Finding Maximum of a series Date Sat, 19 Nov 2011 10:03:25 -0500

```<>

I have a time series dataset ranging from 1940 to 2000. I have to find the
maximum value in series(wage) in the following way:

Maximum wage in 1940 to 1941
Maximum wage in 1940 to 1942
Maximum wage in 1940 to 1943
Maximum wage in 1940 to 1944

and so on till

Maximum wage in 1940 to 2000

Although there are several elementary ways to do this, a useful tool is part of Nick Cox's -egenmore- package on SSC, which contains the egen record() function. That allows you to compute, for instance, the 'record', or largest  value to date, for the time series (In this case the 'record' value is the highest, as in most points scored per World Cup final game, rather than the smallest, e.g., fastest Olympic marathon; record() can do either). By just pulling out values of the new variable for end 1941, end 1942, etc. you have what you refer to above.

webuse wpi1,clear
egen highest_price = record(wpi)

Kit

Kit Baum   |   Boston College Economics & DIW Berlin   |   http://ideas.repec.org/e/pba1.html
An Introduction to Stata Programming  |   http://www.stata-press.com/books/isp.html
An Introduction to Modern Econometrics Using Stata  |   http://www.stata-press.com/books/imeus.html

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```