I have a date field with missing values. I want to replace the missing values with a specified date. I attempted to recode the variable by assigning a value to the missing but it didn't seem to allow xx/xx/xxxx formatted inputs. I attempted to determine the numeric value of my date thinking this was what the recode field wanted but wasn't successful with that either. I'm thinking a compute if statement may be possible i.e. if system-missing input date, but again I'm at a loss on the right commands. Any help would be greatly appreciated!
-
UPDATE: I attempted to redefine the date variable using the 'define variable properties' menu. However, it appears that the "missing values" are actually listed as 10/4/1582. Hopefully someone knows what this means. I should add that the dataset is imported from SQL sp.– jam320Jun 19, 2015 at 14:14
-
UPDATE: I was able to change the "missing values" by opening the dataset in excel, using an if statement to convert the blanks to a specified date, formatting the new column of dates to 'short date', and reopening it in SPSS. I was trying to avoid this by trying to solve it within SPSS so I'd still welcome any solutions if they exist.– jam320Jun 19, 2015 at 14:57
-
You may want to explore why particular records are coming through as missing values in the first instance? Is this expected? Perhaps dates are stored in different formats? MM/DD/YYYY vs. DD/MM/YYYY for example (or any other potential formats)?– Jignesh SutarJun 22, 2015 at 11:29
-
@JigneshSutar I checked the formats . I'm guessing that SPSS had a problem with the column because it had a date subtraction formula in it. So I removed the formula (pasted values only), reopened it in SPSS and it worked.– jam320Jun 23, 2015 at 19:46
2 Answers
You can replace missing values with a specified date like so:
if missing(datevar) datevar = date.mdy(12,20,1999).
exe.
Thanks for all the suggestions - I checked the formats . I'm guessing that SPSS had a problem with the column because it had a date subtraction formula in it. So I removed the formula (pasted values only), reopened it in SPSS and it worked.