# RE: AW: st: Calculate the average bid-ask spread for each centile

 From emanuele canegrati To Subject RE: AW: st: Calculate the average bid-ask spread for each centile Date Fri, 27 Mar 2009 14:11:55 +0100

```It works. Thank you very much indeed!

Emanuele

----------------------------------------
> From: martin.weiss1@gmx.de
> To: statalist@hsphsun2.harvard.edu
> Subject: AW: st: Calculate the average bid-ask spread for each centile
> Date: Fri, 27 Mar 2009 13:09:15 +0100
>
>
> <>
>
>
>
> *************
> clear*
>
> inp str10(day hhmmss) centile
> 20080602 90302 1
> 20080602 90510 1
> 20080602 100408 2
> 20080602 100908 2
> 20080602 160007 100
> 20080602 160107 100
> 20080603 90302 1
> 20080603 90510 1
> 20080603 100408 2
> 20080603 100908 2
> 20080603 160007 100
> 20080603 160107 100
> end
>
>
> *************
>
>
>
> HTH
> Martin
>
>
> -----Ursprüngliche Nachricht-----
> Von: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von emanuele
> canegrati
> Gesendet: Freitag, 27. März 2009 13:07
> An: statalist@hsphsun2.harvard.edu
> Betreff: RE: st: Calculate the average bid-ask spread for each centile
>
> Thank you vary much Maarten. It works. The only problem is that I have the
> same average spread for different days, while I want the mean calculated for
> each centile of each day. In other words, if days are 10 I have now 100
> means, while I should have 10*100 means calculated. Is it possible?
>
> Thank you again.
>
> ----------------------------------------
>> Date: Fri, 27 Mar 2009 11:39:59 +0000
>> From: maartenbuis@yahoo.co.uk
>> Subject: Re: st: Calculate the average bid-ask spread for each centile
>> To: statalist@hsphsun2.harvard.edu
>>
>>
>> --- 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/
> _________________________________________________________________
> Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.
>
> http://www.microsoft.com/windows/windowslive/products/photos.aspx
> *
> * 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/
_________________________________________________________________
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/
*
*   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/
```