[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: replacing incorrect dob values
Kim Price writes:
> I need to replace some date of birth values that were entered
> incorrectly. The variable dob (V1) is entered as %d. I've
> been using variations on the following and coming up with
> error messages:
> replace V1=05sep2046 05sep1946 if id==434
> I want to change id 434's date from 05sep2046 to 05sep1946.
Stata numerically carries dates as days elapsed since 1 jan 1960.
I presume you have the dates in this format, as you claim they
If so, you need to use the date functions -date()- and -d()-, where
date(s1,s2,n) returns the elapsed date corresponding to string s1;
string s2 specifies order of month (m), day (d), and year (y)
in s1. n gives the upper year for converting two-digit years.
d(l) is a date literal convenience function;
e.g., typing d(2jan1960) is equivalent to typing 1.
to edit the values.
For example, you might say
. replace V1 = date("05sep1946","dmy") if id==434
or, more directly,
. replace V1 = date("05sep1946","dmy") if V1 == d(05sep2046)
CONFIDENTIALITY NOTE: This e-mail message, including any attachment(s), contains information that may be confidential, protected by the attorney-client or other legal privileges, and/or proprietary non-public information. If you are not an intended recipient of this message or an authorized assistant to an intended recipient, please notify the sender by replying to this message and then delete it from your system. Use, dissemination, distribution, or reproduction of this message and/or any of its attachments (if any) by unintended recipients is not authorized and may be unlawful.