Dear experts,
I have a problem with importing datetime variables from Excel into Stata – please help me!
Example: Consider the variable datetime for which an example observation in Excel reads '2016-01-31 19:33'. When importing the Excel data into Stata, this observation ‘value’ becomes '1/31/2016 07:33' in Stata. The date format is no problem, but the time is a major problem since it says 07:33 (and not 19:33 or 07:33 pm), making it impossible to tell if it is AM or PM. It thus seems as some information from Excel is lost, but I am sure it is still there somewhere.
The code I have been using reads:
clear all
import excel "excelfile", firstrow
generate double datetime_new = Clock(datetime, "MDYhm")
format datetimevar_new %tCDDmonCCYY_HH:MM
Can someone please tell me what I am doing wrong? I have tried finding the solution in manuals, Statalist, various search engines et cetera - but nothing for days!
Best,
Elisabeth
I have a problem with importing datetime variables from Excel into Stata – please help me!
Example: Consider the variable datetime for which an example observation in Excel reads '2016-01-31 19:33'. When importing the Excel data into Stata, this observation ‘value’ becomes '1/31/2016 07:33' in Stata. The date format is no problem, but the time is a major problem since it says 07:33 (and not 19:33 or 07:33 pm), making it impossible to tell if it is AM or PM. It thus seems as some information from Excel is lost, but I am sure it is still there somewhere.
The code I have been using reads:
clear all
import excel "excelfile", firstrow
generate double datetime_new = Clock(datetime, "MDYhm")
format datetimevar_new %tCDDmonCCYY_HH:MM
Can someone please tell me what I am doing wrong? I have tried finding the solution in manuals, Statalist, various search engines et cetera - but nothing for days!
Best,
Elisabeth
Comment