Statalist The Stata Listserver


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

st: separating string of fixed length into sections


From   Michael McCulloch <[email protected]>
To   Statalist <[email protected]>
Subject   st: separating string of fixed length into sections
Date   Sat, 30 Dec 2006 10:12:49 -0800

Hello,
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 |
+----------+

Before I can use mdy() and date(), I need to split the string into sections:
the first four characters for year,
then the next two for month,
then the last two for day.

How is that done? I've looked at -split- which seems to require a fixed character on which to set parsing, and -parse-, which is outdated.







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