1

I am fairly new to SPSS and not very familiar with string variables. I have a large data set that contains multiple string variables. I know how to convert them into numeric, however, the issue is with data entry. The data was entered by a number of different people, which resulted in misspelled or slightly differently phrased entries. Here is an example:

Normal
Noemal
Normal for her age
Normal for his age
NORMAL FOR HIS AGE
NORMAL FOR HER AGE
normal foe her age
NORMAL etc.

All of these should be recoded into a simple 'normal' so that they can be assigned the same value when converted to numeric. My question is whether there is a way to do that automatically rather than going manually and changing them one by one for each case? (There are around 900 cases and multiple string variables with the same issue, it would take forever to do so).

Thank you for all your help.

Meg90
  • 11
  • 1

1 Answers1

0

The following syntax will take care of the example you gave - other situations might require other solutions...

if char.index(lower(yourvar), "normal")>0 normal=1.

The syntax transforms your original text variable into lower-case and then checks if the text includes the word "normal" - if it does the variable normal receives the value 1.

eli-k
  • 10,898
  • 11
  • 40
  • 44
  • Thank you very much! I'll use the core of the syntax for my other variables as well as it works the way I need it to. Appreciate the help. – Meg90 Jun 27 '22 at 08:54