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]

Re: st: How to replace a missing date with value?

From   Nick Cox <>
Subject   Re: st: How to replace a missing date with value?
Date   Mon, 21 Jan 2013 17:01:24 +0000

There are two problems with your code.

1. Your first -replace- asks for a replacement of the date with the
-date()- equivalent of 29 February 2001. But 2001 was not a leap year,
so there was no 29 February that year, so Stata returns missing, and
nothing is changed.

2. Your second -replace- has exactly the same problem, plus the fact
that what you have supplied is not a DMY argument, but a MDY argument.

So, it seems likely that whatever leads you to apply 29 February is
wrong in this case.


On Mon, Jan 21, 2013 at 4:53 PM, Kanter, Rebecca <> wrote:

> I am trying to replace date value that was missing (.) with the actual value that I now have.
> Given that date1 is a date (DMY) variable in %dM_d,_CY format..
> I do not understand why the below code does not result in the requested change to change date1==. (MISSING) to date1=29feb2001
> replace date1 = date("29-02-2001","DMY") in 23 (via edit)
> (0 real changes made)
>  replace date1 = date("02-29-2001","DMY") if  id=="12345" (via command screen)
> (0 real changes made)
*   For searches and help try:

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