Im using SPSS 16.0 software to clean some data. For each ID, which
represents a person, I have two columns for "date of birth" which
should be the same. However, since they were imported from two
different sources they may be different. One column also has missing
values.
So, I would like to identify the individuals whose date of birth is
not the same in both columns.The formate of the dates is dd-mmm-yyyy.
Thanks to anyone who has a suggestion!
Date variables are numeric, so you can use the usual methods you
would for comparing any two numeric variables. E.g.,
* Read in some data * .
data list list / id (f2.0) dob1 dob2 (2date11).
begin data
1 25-Dec-1980 25-Dec-1980
2 1-Feb-1975 2-Jan-1975
3 17-Mar-1968 .
4 . 11-Nov-1955
5 . .
end data.
* Flag cases where the two DOB variables disagree,
* or where both are missing.
compute dobflag = nvalid(dob1, dob2) LT 2 or (dob1 NE dob2).
format dobflag (f1.0).
var lab dobflag "DOB flag".
val lab dobflag
0 'Two dates agree'
1 'Two dates disagree, or at least one is missing'.
list.
The output should show DOBFLAG = 0 for the first case (because the two
dates match). For the remaining 4 cases, DOBFLAG = 1, because the
dates either mismatch, or at least one of them is missing.
HTH.
--
Bruce Weaver
bwe...@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."
I'm more of a manual person rather than a coder. Here is another
possibility:
Us the recode into a different variable function from the pull down
menus. Create a new date variable, such as Date3. The order of these
steps is important:
If dates are equal, copy the first date
If Date1 is null, copy the second date
If Date2 is null, copy the first date
Review the Date3 column to understand the differences between Date1
and Date2. Determine rules for what date to use when choosing the
best date to use. For example if Date1 was inputted by the user and
Date2 was added from a third party source, always use Date1. Once you
have your rules set up, you can make the changes manually if there are
only a few or set up more recoding into different variables. However,
don't forget to include in the recode logic If Date3=null, otherwise
you'll overwrite your steps above.