Bookmark and Share

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, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re:st: Finding Maximum of a series

From   Christopher Baum <>
To   "" <>
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 Baum   |   Boston College Economics & DIW Berlin   |
                             An Introduction to Stata Programming  |
  An Introduction to Modern Econometrics Using Stata  |

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index