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/