2
votes

I have a column with names and middles names separated by space. Is there a command that will let me put everything after space into a new column? (ie first names and middle names each in their own columns)

I am using SPSS.

Thanks!

1
If you found one of your answers helpful, please consider selecting it as the accepted answer. That will assign credit to the folks who have helped you. - leerssej

1 Answers

2
votes

Assuming the variable to split is called Name, try:

string first middle (a50).
compute #x = char.index(Name, " ") > 0.
do if #x = 1.
   compute first = char.substr(Name, 1, char.index(Name, " ")).
   compute middle = char.substr(Name, char.index(Name, " ")).
else.
   compute first = Name.
end if.
exe.