Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Inaccurate date-time variable
From
rosa <[email protected]>
To
[email protected]
Subject
st: Inaccurate date-time variable
Date
Mon, 17 Oct 2011 15:20:53 +0200
Dear users,
I am having problems generating an accurate date-time variable (using
Stata V 12) using a database of intra-day bank transactions. My final
goal is to declare the dataset to be time series and be able to obtain
a 5minute rolling standard deviation.
The problem is that I have a string variable looking like "2005-01-03
8:34:03" and after transforming and fomating it as desired, some of
the observations of the new date-time variable do not reflect the
exact time as indicated in the original one. So, the date-time
detailed above is transformed to 03jan2005 08:33:37 which is 26
seconds behind the original time. This problem aggravates when
repeated observations are incorrectly generated.
I have transformed the date-time variables using the following command:
gen clock_date2= Clock(clock_date, "YMDhms")
format clock_date2 %tc
And I've also tried to format to ' %tCDDmonCCYY_HH:MM:SS ', however it
gives me the same inaccurate result.
Does anyone have an idea of how can I obtain an accurate date-time
variable and why this error is be happening?
I detail below some of the original and transformed date-time observations:
string var: clock_date clock_date2 (inaccurately transformed variable)
2005-01-03 8:03:31 03jan2005 08:03:02
2005-01-03 8:10:30 03jan2005 08:11:46
2005-01-03 8:11:27 03jan2005 08:11:46
2005-01-03 8:11:47 03jan2005 08:11:46
2005-01-03 8:33:37 03jan2005 08:33:37
2005-01-03 8:34:03 03jan2005 08:33:37
2005-01-03 8:34:35 03jan2005 08:35:48
Thanks a lot in advance,
Rosa
*
* 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/