Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <njcoxstata@gmail.com> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | Re: st: Strings that give missing values as SIF |
Date | Tue, 22 Apr 2014 08:13:23 +0100 |
Consider . di %tdD_M_CY date("31/05/13", "DMY", 2050) 31 May 2013 This is documented in the help for -dates and times-: look for comments on two-digit years. Nick njcoxstata@gmail.com On 22 April 2014 03:14, Paul <paul@iheta.com> wrote: > 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? > > > * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/