Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: How to calculate average in different interval


From   "Mingyuan Guo" <[email protected]>
To   [email protected]
Subject   Re: st: How to calculate average in different interval
Date   Thu, 8 Jun 2006 22:32:41 +1000 (EST)

Hi Gary,

it works. great.

I may have another question to ask, but now not sure. please send an 
thanking email to that guy.

Cheers,

ming

> >Can anyone help me ?
> >
> >I have stock transaction data. I need to calculate each second 
average
> >trading volume. How can I to produce a new variable such as volavg 
and
> >put average volume in the last one of the same second ?
> >
> >order   date            time            price   vol
> >1       1-Jul-05        10:02:19        5.8     5000
> >2       1-Jul-05        10:02:19        5.8     651
> >3       1-Jul-05        10:02:19        5.8     3349
> >4       1-Jul-05        10:02:19        5.8     349
> >5       1-Jul-05        10:02:19        5.8     1500
> >6       1-Jul-05        10:02:19        5.8     5651
> >7       1-Jul-05        10:02:24        5.8     2000
> >8       1-Jul-05        10:02:26        5.8     1000
> >9       1-Jul-05        10:02:26        5.8     37711
> >10      1-Jul-05        10:02:26        5.8     500
> >11      1-Jul-05        10:02:26        5.8     8789
> >12      1-Jul-05        10:02:26        5.8     2000
> >13      1-Jul-05        10:02:35        5.8     2583
> >14      1-Jul-05        10:02:36        5.8     5000
> >
> >
> >The result that I want:
> >
> >order   date            time            price   vol     volavg
> >1       1-Jul-05        10:02:19        5.8     5000    .
> >2       1-Jul-05        10:02:19        5.8     651     .
> >3       1-Jul-05        10:02:19        5.8     3349    .
> >4       1-Jul-05        10:02:19        5.8     349     .
> >5       1-Jul-05        10:02:19        5.8     1500    .
> >6       1-Jul-05        10:02:19        5.8     5651    =
> >(5000+651+3349+349+1500+5651)/6
> >7       1-Jul-05        10:02:24        5.8     2000    2000
> >8       1-Jul-05        10:02:26        5.8     1000    .
> >9       1-Jul-05        10:02:26        5.8     37711   .
> >10      1-Jul-05        10:02:26        5.8     500     .
> >11      1-Jul-05        10:02:26        5.8     8789    .
> >12      1-Jul-05        10:02:26        5.8     2000    =
> >(1000+37711+500+8789+2000)/5
> >13      1-Jul-05        10:02:35        5.8     2583    .
> >14      1-Jul-05        10:02:35        5.8     5000    =
(2583+5000)/2
> >
> >
> >Thanks
> >
> >Gary
> 
> _________________________________________________________________
> Be the one of the first to try the NEW Windows Live Mail.
> http://ideas.live.com/programPage.aspx?versionId=5d21c51a-b161-4314-
9b0e-4911fb2b2e6d
> 
> *
> *   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/
> 
> 

-- 
Mingyuan Guo
[email protected]
EDG 99 Parramatta Campus
School of Economics & Finance
University of Western Sydney
Locked Bag 1797
Penrith South DC NSW 1797
Phone: +61 2 9798 3139
*
*   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