Statalist


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

st: RE: running collapse


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: running collapse
Date   Fri, 21 Nov 2008 09:18:03 +0100

Line for the server...

Sounds like a problem for -h rolling-

HTH
Martin

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Ashim Kapoor
Sent: Friday, November 21, 2008 8:11 AM
To: [email protected]
Subject: st: running collapse

Hello everyone,

I wish to create a " running collapse" . I wonder if this is even the
right command to do this. Here is what I want :-

I have a dataset

Month  Returns
1               .5
1                .6
1                .7
2            etc
2
2
3
3
3
4
4
4
5
5
5
6                  1
6
6

So the command:

collapse (mean) returns, by (month) would generate the mean monthly returns.

But suppose now I want 2 monthly returns   so for February I want the
mean over Jan and Feb, for March I would want the mean over Feb and
March etc.

Now I can do : --
sort month
egen j=group(month)
replace j=j-1 if mod(j,2)==0

THIS DOES group 2 months together but it does not give me a "running
group". For example Jan - Feb would be one group and the next one will
be Mar-April instead of being Feb-Mar.

Has someone dealt with this ?

Thank you,
Ashim.
*
*   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/

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



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index