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   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: separating string of fixed length into sections
Date   Wed, 3 Jan 2007 21:17:02 -0000

Thanks to Svend for the nice plug. -todate- does what 
it aims to do, but it's not going to become an official
Stata command in any foreseeable universe. What 
is needed in this territory is a function or functions 
(strict sense, i.e. _not_ a program) 
for run-together dates which can be applied to individual
dates as well as date variables. At present, the closest users
can get to that is to write a Mata function. 

Nick 
[email protected] 

Svend Juul
 
> 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 |
>         +----------------------+
>  

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