Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

[no subject]



More fundamentally, you would not gain by reducing
"3/12/03" to "31203".

Moreover, -destring- does not possess any special
features for recognising dates or times as such,
presumably on the grounds that other features
are available for that purpose.

Rather, I recommend that you take this
composite variable (-datetime-, say)
and -split- it first.

. split datetime
. gen date = date(datetime1,"dmy",2050)
. format date <whatever>
. drop datetime*

Nick
[email protected]

Eric Hixson

> I have a dataset with dates that I am brining into Stata
> via insheet.  The data is comma delimited and the dates are
> being formatted by the source database like the following:
>
> 3/12/03 0:00:00
> 11/5/03 0:00:00
>
> Unfortunately I can't get rid of the h/m/sec portion at the
> source and Stata is formatting the field as a string.  I
> want to convert the m/d/y portion to a date to allow time
> series analysis.
>
> I tried dstring as a first step and got the following:
>
> . destring dischdate, g(ddate) ignore(" 0:00:00")
> dischdate contains characters not specified in ignore(); no generate
>
> The same error was produced with and without the quotes
> and/or leading space in the ignore statement.  Recast does
> not allow date as a type.
>
> Any thoughts on how to handle the conversion would be appreciated.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index