Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Strings that give missing values as SIF
From
Sergiy Radyakin <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Strings that give missing values as SIF
Date
Mon, 21 Apr 2014 22:59:43 -0400
Paul, why don't you import the Excel file directly to Stata? It will
then pick up the date variables as such and do all the hard work for
you. Best, Sergiy
On Mon, Apr 21, 2014 at 10:14 PM, Paul <[email protected]> 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/