Statalist


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

Re: st: RE: How to calculate the time elapsed between two trading?


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: RE: How to calculate the time elapsed between two trading?
Date   Wed, 15 Oct 2008 00:26:51 +0200

Your message is barely intelligble, and you are messing up the threads in the archive! Anyway, just -outsheet- your data to .txt. or .csv. Or, in Stata 10, use -xmlsave-...

HTH
Martin
_______________________
----- Original Message ----- From: "Jeetendra Aryal" <jeetendra.aryal@umb.no>
To: <statalist@hsphsun2.harvard.edu>
Sent: Wednesday, October 15, 2008 12:23 AM
Subject: RE: st: RE: How to calculate the time elapsed between two trading?


I have very simple question,
- I tried to save a data file in STATA to excel. I tried in as follows: I just copy it from stata to excel but I have problems in the file in excel. Some of the data are now changed in to date. can anyone help me in this?
regards,
Jeetendra

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
statalist@hsphsun2.harvard.edu] On Behalf Of Katia Bobulova
Sent: Tuesday, October 14, 2008 11:09 PM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: RE: How to calculate the time elapsed between two
trading?

Dear Nick,

thank you very much for your help.

It is exactly what I was trying to do.

Thanks

Katia

2008/10/14 Nick Cox <n.j.cox@durham.ac.uk>:
gen byte istrading = trading == "T"
bysort date (istrading time) : gen dt = time - time[_n-1] if istrading
& istrading[_n-1]

This naturally excludes differences between the last trade of a day
and the first trade of the next day, as did your code here.

Nick
n.j.cox@durham.ac.uk

Katia Bobulova

I have to costruct a variable for the time elapsed between two trading
(trading=T)

 I have this situation:

Date               time        control    newvariable
02/01/2007   16:50:55        T         165000
02/01/2007   16:50:56        T         165000
03/01/2007   17:02:30        T         170230
03/01/2007   18:30:20        R            .
03/01/2007   18:32:00        T         183200

Now the result that I would like to reach is to have new variable
which has as observations: 0 and 12970, because the first one is the
result of the diff between the first two newvariable, since they take
place at the same time, the second one should be the difference
between the newvariable at time 17:02:30 and the other one at 18:32:00
(since I am considering just the obs with control=T).

I tried to do this:

gen newvariable= time if control=="T"
by sort date: gen newvariable1=newvariable-newvariable[_n-1]

but I don't have the result that i would like to have, since i am
trying to calculate the time elapsed between two trading(control=T).


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

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index