Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: separating string of fixed length into sections


From   Michael McCulloch <[email protected]>
To   [email protected]
Subject   Re: st: separating string of fixed length into sections
Date   Sat, 30 Dec 2006 13:14:58 -0800

Brilliant! Thanks!

At 12:43 PM 12/30/2006, you wrote:
Michael wrote:

I have a date string which I'd like to convert to Stata date.

. list datedx in 1/5
   +----------+
   |   datedx |
   |----------|
1. | 19900417 |
2. | 19880107 |
3. | 19930407 |
4. | 19880819 |
5. | 19880927 |
   +----------+

How is that done?
-------------------------------------------------------------------
There were suggestions. However, as so often before,
Nick Cox has made a nice solution, -todate-. It
deserves to be official, but isn't (yet). Install
it by:
   ssc install todate

With Michael's five observations :

   todate datedx , gen(datedx2) pattern(yyyymmdd)
   format datedx2 %d
   list
        +----------------------+
        |   datedx     datedx2 |
        |----------------------|
     1. | 19900417   17apr1990 |
     2. | 19880107   07jan1988 |
     3. | 19930407   07apr1993 |
     4. | 19880819   19aug1988 |
     5. | 19880927   27sep1988 |
        +----------------------+

Happy New year

Svend
________________________________________________________

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000 Aarhus C,  Denmark
Phone, work:  +45 8942 6090
Phone, home:  +45 8693 7796
Fax:          +45 8613 1580
E-mail:       [email protected]
_________________________________________________________

*
*   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/

Best wishes,
Michael


____________________________________

Michael McCulloch
Pine Street Clinic
Pine Street Foundation
124 Pine Street, San Anselmo, CA 94960-2674
tel     415.407.1357
fax     415.485.1065
email:  [email protected]
web:    www.pinest.org
        www.pinestreetfoundation.org
        www.medepi.net/meta





*
*   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