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

Re: st: String -> date format conversion with insheet


From   Roger Newson <roger.newson@kcl.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: String -> date format conversion with insheet
Date   Fri, 21 Nov 2003 16:12:59 +0000

At 10:52 21/11/03 -0500, Eric Hixson wrote:
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.
Use -split- to split the string into date and time. Then convert the date in the usual way.

Roger


--
Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
or 020 7848 6605 International +44 20 7848 6605
Email: roger.newson@kcl.ac.uk
Website: http://www.kcl-phs.org.uk/rogernewson

Opinions expressed are those of the author, not the institution.

*
* 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index