Objective
I am converting a vector of strings of the following format "MM/DD/YYYY HH:MM:SS"
to a Stata recognizable datetime using the clock()
function.
The problem
The resulting converted datetime is not equivalent to the input. Here is the code that I've used,
gen datetime = clock(dt, "MDY hms")
format datetime %tc
and here is the resulting data, where the original string is dt
and is a str19 type in %19s format and datetime
is the converted variable as a float formatted as %tc,
dt | datetime |
---|---|
1/1/2016 1:00:00 | 01jan2016 01:00:27 |
1/1/2016 2:00:00 | 01jan2016 01:59:25 |
1/1/2016 3:00:00 | 01jan2016 03:00:35 |
1/1/2016 4:00:00 | 01jan2016 03:59:34 |
What I've done
I have read through the the Stata User Manual's Chapter 24 Working with dates and times as well as Datetime translation and could not parse out any clues to what is happening, so any help is greatly appreciated.
Sample Data
clear
input str19 dt
"1/1/2016 1:00:00"
"1/1/2016 2:00:00"
"1/1/2016 3:00:00"
"1/1/2016 4:00:00"
"1/1/2016 5:00:00"
"1/1/2016 6:00:00"
"1/1/2016 7:00:00"
"1/1/2016 8:00:00"
"1/1/2016 9:00:00"
"1/1/2016 10:00:00"
end