you could also do something like this.
dataset close all.
DATA LIST LIST
/ variable (A15).
BEGIN DATA.
"1, 2, 3, 4"
"2, 3, 2, 4"
"5, 2, 1, 4"
"3, 2, 1, 2"
"6, 2, 1, 9"
END DATA.
string v1 to v4 (a3).
vector temp=v1 to v4.
loop i=1 to 4.
compute a=char.index(variable,', ').
compute temp(i)=char.substr(variable,1,a-1).
if a>0 variable=char.substr(variable,a+2,100).
if a=0 temp(i)=substr(variable,1,75).
end loop.
execute.
------------------------------
Art Jack
------------------------------
Original Message:
Sent: Sat January 14, 2023 02:37 PM
From: Tamar Wilner
Subject: How to separate values entered as one variable in list format to multiple variables?
Hi - I am also interested in addressing the same issue. But when I search for SSPSinc Trans, I don't see any extensions by that name.
Also, could you spell out what we would need to change in the above code to suit our dataset? Is "v1 to v10" the names of the new variables, and where does the name of the old variable go?
Thank you!
------------------------------
Tamar Wilner
Original Message:
Sent: Mon October 19, 2020 02:06 PM
From: Community Support Admin
Subject: How to separate values entered as one variable in list format to multiple variables?
You could write a loop to find the parts and save separate variables, but the easiest way would be to use the SPSSINC TRANS extension command, which you can install from the Extensions > Extension Hub menu.
Then this code would do it. I assumed the variable is named x and there could be up to ten values.
spssinc trans result=v1 to v10 type = 0
/formula 're.split(",", x)'.
#SPSSStatistics
#Support
#SupportMigration