Reputation: 418
I am new to the SPSS platform and i got a complicated dataset to work with in SPSS.
The data look like this
header1|header2|header3|{header4_a - header4_b - header4_c} |{header5_a - header5_b - header5_c} |{header6_a - header6_b - header6_c}
1|some-text-can be here| 2 |{ Alex - John,Doe - 20}|{ Maria - Maria,Doe - 300}
2|some-other text| 1 |{ Mike- Mike,Doe - 400}
I would love some guidance how to open this file so i can work on each header4_a header4_b etc separately.
Upvotes: 1
Views: 56
Reputation: 11360
I suggest you read the file using only the pipes as delimiters. Headers 4a-4c will be read into a single variable (the same with 5a-5c) which will be easy to separate into 3 variables as you described.
Use syntax along these lines:
*first creating some fake data to experiment on.
data list list/header4(a30).
begin data
"{Alex - John,Doe - 5005}"
"{ Maria - Maria,Doe - 300}"
end data.
* now cleaning and dividing `header4`.
string header4_a header4_b header4_c (a20).
compute header4=replace(replace(header4,"{",""),"}","").
compute header4_a=char.substr(header4,1,char.index(header4,"-")-1).
compute header4_b=char.substr(header4,char.index(header4,"-")+1).
compute header4_c=char.substr(header4_b,char.index(header4_b,"-")+1).
compute header4_b=char.substr(header4_b,1,char.index(header4_b,"-")-1).
exe.
Upvotes: 1