Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: replacing incorrect dob values


From   Ronan Conroy <[email protected]>
To   "statalist hsphsun2.harvard.edu" <[email protected]>
Subject   Re: st: replacing incorrect dob values
Date   Thu, 24 Oct 2002 10:24:02 +0100

on 23/10/02 6:43 pm, Kim Price at [email protected] wrote:

> 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

-replace- needs the old value and the new value.  And the variable you are
changing is a string variable. You need to surround the old and new values
with quotes

> replace V1="05sep1946" if id==434

or

> replace V1="05sep1946" if V1=="05sep2046"

However, this is a brute force solution. Consider: if people have impossible
birthdates, then they will have a minus age. Consider

1. calculating age normally
2. then using

replace age=age-100 if age < 0

 


Ronan M Conroy ([email protected])
Lecturer in Biostatistics
Royal College of Surgeons
Dublin 2, Ireland
+353 1 402 2431 (fax 2329)

--------------------

*
*   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