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

st: (Moving Maximum in Unbalanced panel) Max of a variable in the last 12 months?


From   Sergio Correia <[email protected]>
To   [email protected]
Subject   st: (Moving Maximum in Unbalanced panel) Max of a variable in the last 12 months?
Date   Tue, 5 Jul 2005 19:30:54 -0500

Hi all,

I'm trying to generate a variable "Y" that is the maximum value of
another one (lets call it "X") in the last 12 months.

Now, I'm using an unbalanced panel, so I think I need to use a "by id:" command.
I have already set the time series and the panel identifiers ("date"
and "id"), so I can use the lag and difference operators to take
account of the nature of the panel.

My problem is that I need the maximum value with respect to every
month and every id.
Previously, I needed to calculate the maximum value in the last 12
months, with respect to the last date of the panel (2004m12). So I
just did a drop "if date<2004m1"

But now I need to calculate the max. for every month.. that is, the
**moving maximum, for each ID, taking into account the unbalancedness
of the panel**.

Any ideas? I'm kinda stuck here =)
Thanks a lot!

Sergio

PS: I'm using StataSE 8

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