I'm working with a series of dates and times and my code is changing the year from 2022 to 1962.
I have date and time as two separate variable:
format closest_date %tdnn/DD/YY
format closest_time %tcHH:MM:SS
I'm using this code to merge date and time into one variable:
gen double closest_dts = closest_date*24*60*60*1000 + closest_time
format closest_dts %tcnn/DD/YY_HH:MM:SS
gen double datetime=date*24*60*60*1000+time
format datetime %tcDD/NN/CCYY_HH:MM:SS
closest_date closest_time closest_dts
1/04/2023 14:44:03 1/04/1963 14:44:03
Is anyone able to advise where I'm going wrong with my code?
Thanks,
Katie
I have date and time as two separate variable:
format closest_date %tdnn/DD/YY
format closest_time %tcHH:MM:SS
I'm using this code to merge date and time into one variable:
gen double closest_dts = closest_date*24*60*60*1000 + closest_time
format closest_dts %tcnn/DD/YY_HH:MM:SS
gen double datetime=date*24*60*60*1000+time
format datetime %tcDD/NN/CCYY_HH:MM:SS
closest_date closest_time closest_dts
1/04/2023 14:44:03 1/04/1963 14:44:03
Is anyone able to advise where I'm going wrong with my code?
Thanks,
Katie
Comment