Hi Statalist,
Sorry for asking questions about date and time. I really did look through the
help datetime.
I am working with an inconsistent string variable from old parish registers, that have text, brackets, years, months and days mixed in different orders, while I need to extract the year. What gave me hope was that the code Y in mask for date() only converts 4-digit numbers Since this is the only reliable consistency I have found. So I managed to convert a fraction of the observations using:
It gave me changes where the year was the first four digits, but I have been struggling to find a function to ignore the text and characters before Y. # seems to have limited capacity when placed in front of #Y.
The topyear function gave me hope for sorting away impossible dates, but it seems to only function for 2-digit years? I am hoping to limit this converstion to those 4-digit numbers that start with 16, 17, 18 and 19, as my data is primarily from those centuries. Sorry for the inconvenience. Sincerely a historian from Norway
Sorry for asking questions about date and time. I really did look through the
help datetime.
I am working with an inconsistent string variable from old parish registers, that have text, brackets, years, months and days mixed in different orders, while I need to extract the year. What gave me hope was that the code Y in mask for date() only converts 4-digit numbers Since this is the only reliable consistency I have found. So I managed to convert a fraction of the observations using:
Code:
gen bapdate = date(daapsdato, "Y#")
The topyear function gave me hope for sorting away impossible dates, but it seems to only function for 2-digit years? I am hoping to limit this converstion to those 4-digit numbers that start with 16, 17, 18 and 19, as my data is primarily from those centuries. Sorry for the inconvenience. Sincerely a historian from Norway

Comment