Hello dear community!
I am referring to the attached screenshort where you see two columns containing start and end dates with very hetereogeneous formatting. As of now, both columns are stored as strings since "UnKnown" was inserted everytime no date is given. I am now (1) trying to convert these strings to dates and (2) seeking to extract the year from all these dates. Step 2 is fairly straightforward, but I am struggling with the conversion. There are three different formats: e.g. a.) 18.Jul 14; b.) 1995 and c.) Feb 73. Only the last two digits of the years are shown in cases a.) and c.) so that I would need insert "20" whenever the number are [0,19] and a "19" otherwise. I have been experimenting a lot with date() but failed as of now.
Did someone already encounter a similar problem and could provide me with some insight?
Thanks!
Marie
Related Posts with convert strings into date variables with very heterogeneous formats
How to convert strings to date variable?For example, a date of 81.511, corresponds to 06/07/1981(DMY). How do you convert this to a Stata da…
Creating an adjacency matrix from two columnsDear Statalists, I have 2 columns (id and course) I would like to create two types of adjacency ma…
Every time I type the command 'mmsel', I get a 'file tmp / xfbf.dta not found' error.I try to implement wage decomposition based on Machado and Mata (2005). I would be grateful if you c…
Factor variables vs. dummy variables with interactionsHi all, I have a dummy variable x1 (no missing values) in the dataset and has values of 0 and 1, an…
percentage change of lagged variableI have another related query on generating lagged variables. My regression model looks like this: In…
Subscribe to:
Post Comments (Atom)
0 Response to convert strings into date variables with very heterogeneous formats
Post a Comment