Statalist


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

st: Help with data management


From   Katia Bobulova <[email protected]>
To   [email protected]
Subject   st: Help with data management
Date   Fri, 11 Jul 2008 17:24:23 +0100

Dear all,

I have some problems in managing my dataset. I have a dataset with
high frequency data, with observations about time, date, price,
quantity and a code for the type of security.

I have three questions:

1) I have the time in this format: 63000 and i want to construct a
"timedate" variable, which contains both the data and the time.

First af all I tried to modify the format of the time typing:

g hours=int(time/10000)
g minutes=int((time-hours*10000)/100)
g seconds=int(time-hours*10000-minutes*100)
g newtime=hms(hours, minutes, seconds)
format newtime%tc

However, after typing hms() I receive this message:
Unknown function hms()
r(133);

The next step would be typing something like:

gen double timedate=date*24*60*60*1000+time
format timedate %tcNN/DD/CCYY_HH:MM:SS

2)I have two types of prices: price1 and price2. I would like to
create a variable which takes the difference between the lowest value
of price1 and the highest value of price2 for each data and time.

First of all I sorted my dataset:

sort date time price1 price2

then I generated the new variable:

gen price3=(price1[_n]-price2[_N] & date==(26feb2008) & time==63000

But as a result I have all missing values, furthermore I have  to do
this for each date and time, so i was wondering if there is a way to
instruct Stata to create this new variable for each time and data.

3) I have to divide my variable time in equal time intervals. For
example, i have observations at 14:41:38 and 15:28:32 and I would like
to have observations at precise time intervals, for example each
5-minute, i.e. at 14:40:00, 14:45:00 and so on. Any idea on how to do
this?

I really need help so I would really appreciate any suggestion, also
for only of the three questions.

Thank you very much for your time.

Best,
Katia

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