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
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Strings that give missing values as SIF
Date
Tue, 22 Apr 2014 09:48:31 +0100
Stata requires the century to be explicit. It could have been written
with a convention that "within the last 100 years" is taken to be
implicit, but then the meaning of code would vary according to the
instant it was executed. That's not a good idea.
Nick
[email protected]
On 22 April 2014 08:18, Paul <[email protected]> wrote:
> Thank you, in the end your way was the simplest.
> Paul
>
> On 22/04/14 12:59 PM, "Sergiy Radyakin" <[email protected]> wrote:
>
>>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/
>
>
>
>
> *
> * 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/
*
* 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/