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

Re: st: replace two characters within an eight-character string

From   n j cox <>
Subject   Re: st: replace two characters within an eight-character string
Date   Sun, 04 Nov 2007 17:47:58 +0000

-todate- is from SSC. (You are asked to indicate where non-official
commands you use come from.) In Stata 10, it is largely superseded
by an enhanced version of -date()-. If you are still using Stata 9
or some earlier version, please do make that explicit in future
postings, as otherwise advice may not apply to your version of

-todate-'s failure to provide dates here seems reasonable.

If I were imputing day of month when month and year were known, I would use the 15th as closer to the midpoint of the months. That might
be better (or worse) for your purpose.


Michael McCulloch

How can I replace characters at specific locations within an
eight-character string?

I'm using -todate- with mostly good success to convert an
eight-character string to Stata date, except when a month or day
within that string is unknown. That would be coded "99", as in:
"01991994", for "some day in January, 1994"

I'd like to edit that string to "01011994". Can this be done?

Tangentially, my code is:
todate datevar, gen(newdatevar) p(mmddyyyy) f(%dd_m_cy)
format datechemo %d

* For searches and help try:

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