Reputation: 1
I'm trying to recode system missing value into the same variable in SPSS, the variable is a date and the format is dd-mmm-yyyy. (mmm is for example Aug or Feb etc) So what I did was: Transform > Recode into same variable > select variable > Old and New Values > Old Value = System-missing, New Value = 09041853 (just because I need a date that would not occur in my dataset)> Add > Continue > Ok.
Bu the result is: 26-Jan-1583, that is a completely different date.
I had to enter the date like 09041853, because I could not put a - ? ., I have also tried a different format dd.mm.yyyy and different date in the future, but that also became a different date in the past.
I also don't know now what to fill in as missing value, can someone help me solve this?
Upvotes: 0
Views: 499
Reputation: 189
I don't know why you would even need to input any "fake" date into the cells with missing data. I personally would just leave them empty so that SPSS recognises these cells as system missing.
But if you're set on putting the date "09-04-1853" in the missing cells I found a very roundabout way of doing that.
First, set the type of your date variable (let's call it "old_variable") to string. If you then go into the data view you will see that the empty cells will have some weird string in them with lots of empty spaces, like
" ."
(SPSS seems to be pretty buggy here. Sometimes it showed this string with the period, sometimes it didn't - changing the alignment of the variable from left to right seemed to reveal it).
I then had to copy this string " ."
and input it to the recode command to replace it with the desired date. I think this is necessary because when changing the original variable from date to string the cells in the string variable are not system missing anymore, but instead have " ."
inside them, therefore trying to replace missing values in the string variable with "09-04-1853" would not work.
You can then either create a new variable:
STRING new_variable (A12).
RECODE old_variable (' .'='09-04-1853') (ELSE=Copy) INTO new_variable.
EXECUTE.
Or change the old one:
RECODE old_variable (' .'='09-04-1853').
EXECUTE.
Then you just change the type back to date and you have your new variable with the desired date instead of empty missing value cells.
Again, I do not understand why you would want to do that. Also, there is probably a much cleaner less hacky way to do this but this is the best I could come up with at the moment.
Upvotes: 0