Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: imputing dates into a string date

From   Tim Evans <>
To   "''" <>
Subject   st: imputing dates into a string date
Date   Thu, 7 Jun 2012 14:16:21 +0100

Hi all,

I have dates in the form DMY in a string variable 

i.e. 22/01/2010

I am generating numerical dates using the following code:

generate double dx2 = date(dx, "DMY")
format %tdDD/NN/CCYY dx2

This is working fine, until I come across a date that actually starts like this:


Then my code to generate a date returns a blank. What I would like to do is add in something that allows me to evaluate whether the day is xx and if so, insert 01.

Am I to assume I need something like regexm 

if regexm(dx2, "^XX") == 1
	replace"XX" = 01

generate double dx2 = date(dx, "DMY")
format %tdDD/NN/CCYY dx2

If you have any ideas, that would be great.

This email and any attachments hereto contains proprietary information, some or all of which may be confidential or legally privileged. It is for the exclusive use of the intended recipient(s) only. If an addressing or transmission error has misdirected this e-mail and you are not the intended recipient(s), please notify the author by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail or any attachments, as this may be unlawful.

*   For searches and help try:

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