Statalist


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

Re: st: Calculate the average bid-ask spread for each centile


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Calculate the average bid-ask spread for each centile
Date   Fri, 27 Mar 2009 11:39:59 +0000 (GMT)

--- On Fri, 27/3/09, emanuele canegrati  wrote:

> I have a time series of bid-ask spreads, grouped in
> centiles, with respect to trading time. Now I want to
> calculate the average spread for each centile. The structure
> of data is the following
>  
> day          spread   hhmmss  centile
> 20080602     xxxx     090302   1
> 20080602     xxxx     090510   1
> ...
> 20080602     xxxx     100408   2
> 20080602     xxxx     100908   2
> ...
> 20080602     xxxx     160007   100
> 20080602     xxxx     160107   100
> ...
> 20080603     xxxx     090302   1
> 20080603     xxxx     090510   1
> ...
> 20080603     xxxx     100408   2
> 20080603     xxxx     100908   2
> ...
> 20080603     xxxx     160007   100
> 20080603     xxxx     160107   100
> ...
>  
> What is the loop I have to write?

no loop necesary:

bys centile : egen mspread = mean(spread)

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://home.fsw.vu.nl/m.buis/
-----------------------------------------





      

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