I'm looking to Find and Replace in SPSS but ideally using syntax, not the CTRL+F.
And I need it for something fairly specific. I have a dataset with 100 variables. In all variables, I want to search for any cell that says "na" and replace it with just "" (a blank).
But I dont want any instance of "na", for example in the word "Anna", I just want if the entire contents of the cell says "na" make the cell "" instead.
How can I achieve this with syntax for all columns in the dataset?
Thanks!
If you wanted to delete every instance of "na" within the text this would do it:
do repeat vr=yourfirstvar to yourlastvar.
compute vr=replace(vr, "na", "").
end repeat.
If on the other hand you want to replace only when the full value is "na" use this instead:
recode all ("na"="").
Note: both answers here assume all your variables are text and not numeric. If you have both types mixed together you should put the variable names in the command instead of all
, or use varX to varY
if they are text variables and are contiguous in the dataset.