Bookmark and Share

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]

Re: st: RE: Inaccurate date-time variable


From   rosa <[email protected]>
To   [email protected]
Subject   Re: st: RE: Inaccurate date-time variable
Date   Mon, 17 Oct 2011 16:07:45 +0200

Thanks for the quick response. I forgot to mentioned that I have tried
using clock() before. However, something is wrong since although I do
obtain:
. di %tc clock("2005-01-03 8:34:03",  "YMDhms")
03jan2005 08:34:03

I still continue obtaining inaccurate date-time observations when
running the following code:
gen clock_date2= clock(clock_date, "YMDhms")
format clock_date2 %tc

How is this possible?

As shown below, I am still getting inaccurate times when using
clock(). I don't get to identify where's the problem.

string var: clock_date  clock_date2
2005-01-03 8:03:31	 03jan2005 08:03:02
2005-01-03 8:10:30	 03jan2005 08:09:35
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:33:37
2005-01-03 8:43:47	 03jan2005 08:44:32

Thanks again.

Rosa

On 10/17/11, Nick Cox <[email protected]> wrote:
> -clock()- and -Clock()- are different functions: see e.g. the help for
> -clock()- which also includes detail on -Clock()-
>
> . di %tc clock("2005-01-03 8:34:03",  "YMDhms")
> 03jan2005 08:34:03
>
> . di %tc Clock("2005-01-03 8:34:03",  "YMDhms")
> 03jan2005 08:34:25
>
> Changing the format will naturally do nothing to fix this; that just changes
> how an incorrect number is displayed. You just need to use the right
> function.
>
> Nick
> [email protected]
>
> rosa
>
> 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
>
>
> *
> *   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index