[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
RE: st: replacing incorrect dob values
Ronan Conroy replied to Kim Price:
> > 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
> > 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
Pertinent if the date variable were being
held as string; but as implied by stated %d
format, it is being held as a Stata date,
namely as integers with base 1 January 1960.
That is, you cannot assign format %d to
a string variable.
* For searches and help try: