1

May I know how I can convert the data in SPSS Modeler as the image below?

enter image description here

I have read How to restructure data in SPSS Modeler? and tried Restructure but it did not generate format like "From_1", "To_1", etc.

Greatly appreciate any help/advice. Thanks a lot in advance.

eli-k
  • 10,898
  • 11
  • 40
  • 44
StephL
  • 27
  • 4

1 Answers1

0

The following syntax will work in SPSS:

(this part is just to reconstruct your example)

data list list/ID (F3) Date (Edate8) xfrom xto (2A3).
begin data
    881    01/01/22    "abc"    "def"
    881    02/01/22    "dfd"    "gdk"
    883    10/01/22    "gbd"    "kiu"
    883    14/01/22    "hdd"    "kkh"
end data.

Now for the restructure - before you can use casestovars for restructure, you need an index of cases in each ID:

sort cases by ID Date.
compute ind=1.
if $casenum>1 and ID=lag(ID) ind=lag(ind)+1.
exe.
formats ind (f1).
casestovars /id=ID/index=ind/separator="_".
eli-k
  • 10,898
  • 11
  • 40
  • 44
  • Thanks so much! I guess the casestovars command is for SPSS Statistics only? I am using SPSS Modeler and could not find the equivalent operation... Appreciate your further advice. Greatly appreciated in advance. – StephL Feb 21 '22 at 14:06
  • Sorry I don't have (knowledge about) SPSS modeler myself, but I think you can run some SPSS [syntax from SPSS modeler](https://www.ibm.com/docs/en/spss-modeler/18.1.1?topic=nodes-spss-statistics-overview) – eli-k Feb 21 '22 at 15:11