I am using Stata ic 13.1 for mac 64 bit Intel
I imported into Stata a csv file with 4083 patient responses recorded at an import_date. The recorded format of that date in Excel is DD/MM/YY h:mm, and is shown as a str13 variable
My attempt to get an SIF date as DD/MM/YY in stata followed the sequence below
1. I first stripped off the h:mm in import_date
gen Time=substr(import_time,1,8) list Time in 1/10 * +----------+
* 1. | 31/05/13 | * 2. | 28/05/13 | * 3. | 21/03/13 | * 4. | 30/04/13 | * 5. | 13/05/13 | * |----------| * 6. | 28/05/13 | * 7. | 17/04/13 | * 8. | 30/04/13 | * 9. | 16/05/13 | * 10. | 30/04/13 | * +----------+ 2. This new format seems OK but Time is shown as a str9 variable with format %9s. I tried
gen ImportTime = date(Time, "DMY") format ImportTime %td
The result was *(4083 missing values generated)
3. Noting that some days were 1-9, I tried adding an extra 0 in front of the day in import_date using
*replace import_time = "0" + import_time if length(import_time) == 7
4. To no avail as the 4083 missing values message was repeated when I recalculated ImportTime
I am missing something in my reading of stata dates and times or in importing excel csv to stata.Any ideas?
|