Dear all,
I am processing hourly time series data (DD.MM.YYYY hh:mm), where the date variable is formatted as a string and looks the following:
. list datestring
datestring
1. 01.04.2018 00:00
2. 01.04.2018 01:00
3. 01.04.2018 02:00
4. 01.04.2018 03:00
5. 01.04.2018 04:00
To convert the string variable into a date variable, I run the following code:
gen Datetime = clock(datestring, "DMYhm")
format Datetime %tc
This is what I get:
. list Datetime datestring
+---------------------------------------+
| Datetime datestring |
|---------------------------------------|
1. | 01apr2018 00:00:19 01.04.2018 00:00 |
2. | 01apr2018 00:59:18 01.04.2018 01:00 |
3. | 01apr2018 02:00:28 01.04.2018 02:00 |
4. | 01apr2018 02:59:27 01.04.2018 03:00 |
5. | 01apr2018 04:00:37 01.04.2018 04:00 |
+---------------------------------------+
However, "Datetime" and "datestring" are not equivalent. For example, in row 2 the clock time is 00:59:18, whereas it should be 00:01:00.
I believe that this "mismatch" stems from the missing seconds in the variable "datestring", but I do not know how to fix this. Any help would be much appreciated!
Many thanks in advance!
Mario
Related Posts with Mismatch between date formatted as string and numeric date
Drop all values other than month-end dates where the dates dont always end on standard monthend say there would be a value 27th May.Hi, I have a file with a date column and 5 other daily return columns. File attached. I use the bel…
Formulating a Parametric Translog Input Distance Function in order to get technical efficiency and elasticity of substitutionI am using a panel data set for the manufacturing industries (firm-level data) for about 20 years, w…
Installing "femlogit"Hi there, I am using STATA from a server which is not connected to the internet and therefore does …
Handling missing data in matched case-control data-setDear all, I would like to ask handling missing data in case control data-set (1:2) matched on age a…
How to? Chi test of homogeneity for categorial variablesHi guys, Below i have included a sample of my two categorial variables. How do i perform a Chi^2 te…
Subscribe to:
Post Comments (Atom)
0 Response to Mismatch between date formatted as string and numeric date
Post a Comment