I have several variables that are a mixture of dates and times. I do not need the times and would just like to remove them. For example, a date such as 03oct2019 16:20:00 would just need to be shortened to 03oct2019 in order to be consistent with other dates. I have tried the code below but it's not giving me what I want. When I tried to convert the date back to a string in order to use the "DMY#", I get an error that says cannot be reversibly converted.
----------------------- copy starting from the next line -----------------------
------------------ copy up to and including the previous line ------------------
----------------------- copy starting from the next line -----------------------
------------------ copy up to and including the previous line ------------------
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str7 id double(first_date_of_recruitment last_date_of_recruitment) "1" 1.8857388e+12 . "2" 1888391520000 . "3" 1.8883725e+12 1.8909549e+12 "5" 1891002480000 . "7" 1.8884376e+12 . "11" 1891023360000 . "13" . . "19" 1890964620000 . "30" . . "32" . 1883241780000 end format %tcDD-NN-YY first_date_of_recruitment format %tcDD-NN-YY last_date_of_recruitment
----------------------- copy starting from the next line -----------------------
Code:
foreach var of varlist first_date_of_recruitment last_date_of_recruitment{ generate double `var'2 = clock(`var', "YDM hms") format `var'2 %tcDD-NN-YY }
Comment