I am attempting to convert a variable <date> obtained from a registry database, which displays using list as: 17oct1940 00:00:00.
Codebook identifies this as a numeric (double) variable type, with range: [-8.795e+11,9.938e+11] .
I have used the following 3 approaches to attempt to convert this to a Stata Internal Date ( with error message following "//"):
gen newborn=date(string(zanzip_dateborn), "DMY") // generates empty var
gen newborn2=substr(string(zanzip_dateborn), 1,9) // generates odd numbers such as -772000000000
numdate newborn3 = zanzip_dateborn, pattern(DMYhms) // Unrecognized kind of date-time
I'm familiar with using -date- and -todate- from simple strings or numeric variables, but this one has me stumped.
I'm not able to simulate an example, as the following code returns error "cannot be read as number":
Any advice would be very much appreciated.
Michael
Codebook identifies this as a numeric (double) variable type, with range: [-8.795e+11,9.938e+11] .
I have used the following 3 approaches to attempt to convert this to a Stata Internal Date ( with error message following "//"):
gen newborn=date(string(zanzip_dateborn), "DMY") // generates empty var
gen newborn2=substr(string(zanzip_dateborn), 1,9) // generates odd numbers such as -772000000000
numdate newborn3 = zanzip_dateborn, pattern(DMYhms) // Unrecognized kind of date-time
I'm familiar with using -date- and -todate- from simple strings or numeric variables, but this one has me stumped.
I'm not able to simulate an example, as the following code returns error "cannot be read as number":
Code:
clear input date 17jul1935 00:00:00 end
Michael
Comment