Statalist


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

st: replace two characters within an eight-character string


From   Michael McCulloch <[email protected]>
To   Statalist <[email protected]>
Subject   st: replace two characters within an eight-character string
Date   Sat, 3 Nov 2007 16:05:15 -0700

Dear Statalist members,
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

Thank you,
Michael



-- 

Michael McCulloch
Pine Street Foundation
124 Pine St., San Anselmo, CA 94960-2674
Tel:	(415) 407-1357
Fax:	(415) 485-1065
[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