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   "Svend Juul" <[email protected]>
To   <[email protected]>
Subject   Re: st: separating string of fixed length into sections
Date   Sat, 30 Dec 2006 21:43:54 +0100

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/



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