Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SPSS String Column Split into 2

Tags:

spss

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!

like image 730
user3047435 Avatar asked May 15 '26 15:05

user3047435


1 Answers

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.
like image 167
Ritchie Sacramento Avatar answered May 18 '26 05:05

Ritchie Sacramento



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!