Hunderte von Datensätzen zusammenführen

Alles rund um SPSS Syntax und Programmierung.

Hunderte von Datensätzen zusammenführen

Beitragvon yann » So 5. Mai 2013, 20:43

Hallo liebes Forum,

nachdem mir schon einige Kniffe mit SPSS gelungen sind was Stapelverarbeitung betrifft, komme ich nun bei der Operation nicht mehr weiter, die ich für die einfachste gehalten hatte. Es wäre großartig, wenn jemand mir hier weiterhelfen könnte.

Folgendes Problem: ich habe einige hundert gleichförmiger Datensätze mit jeweils einem Fall, die Variablen sind überall die gleichen. Nun soll daraus natürlich ein Datensatz werden um damit arbeiten zu können. Das geht in SPSS ja über die Funktion "Daten > Dateien zusammenfügen > Fälle hinzufügen" - allerdings immer nur eine Datei nach der anderen. Wie kann ich mithilfe einer Syntax oder eines Makros (oder anderem Vodoo?) sämtliche SAV-Dateien z.B. innerhalb eines Ordners zusammenführen?

Ich bin für jede Hilfe dankbar! Python Essentials und SPSSINC PROCESS FILES sind installiert - allerdings komme ich nicht drauf, wie ich die Syntax komponieren muss, damit das gewünschte Resultat rauskommt. I have no idea what I'm doing. :)

Vielen Dank und viele Grüße
Nico
yann
 
Beiträge: 2
Registriert: So 5. Mai 2013, 20:36
Danke gegeben: 0
Danke bekommen: 0 mal in 0 Post

Re: Hunderte von Datensätzen zusammenführen

Beitragvon yann » Sa 11. Mai 2013, 16:54

Okay - vielen Dank, das hat sich erledigt. Für den Fall, dass jemand auf der Suche nach einer Lösung für das gleiche Problem ist, das hier habe ich gerade im Forum von IBM Developer Works (https://www.ibm.com/developerworks/community/forums/html/topic?id=40c6d8af-8223-497f-8efe-6a642b342c1f) geposted:


Thanks again, Jon and RCCG. Your combined suggestions solved my problem!

OK, so here's what I did and I hope future googlers typing "merging multiple data sets" or "merging hundreds of data sets" find this response and save time. I still find it very complicated and wonder why SPSS doesn't have this on board anyway but then again SPSS is lacking a lot of functions I consider elemental.

1. I made sure all the data sets I wished to combine were in *.sav-format and stored in the same folder.
2. I created a file list of that folder with the Windows command prompt by navigating to said folder and executing the command "dir /b > list.txt"
3. I edited this list and added '/FILE "{directory}/" at the beginning of each line (where {directory} equals the file's directory of course) and a simple " at the end of each line. (quite easily accomplished by putting them into seperate columns of an excel table and then copying and pasting the result into a text editor - make sure to find and replace all the blanks/separators between columns)
4. I created a new syntax as follows:

Code: Alles auswählen
    ADD FILES /FILE=*

    EXECUTE.


5. Ultimately I proceeded to copy and paste 49 lines of the above list in between "ADD FILES" and "EXECUTE." at a time, making sure to not forget the "." at the end of the last line of each package and ran the syntax.
6. I proceeded with step 5 until I had copied, pasted and executed all of the lines of my txt.

Took me about twenty minutes to half an hour but just because I had some other stuff messed up in the data sets. Maybe there is an easier solution to this, but this was quite doable and definitely faster than doing it via the UI of SPSS.

Thanks to JonPeck and RCCG_荣_黄 for helping me find this solution. Good day to everyone and happy analyzing!

Regards
Nico
yann
 
Beiträge: 2
Registriert: So 5. Mai 2013, 20:36
Danke gegeben: 0
Danke bekommen: 0 mal in 0 Post


Zurück zu SPSS Syntax

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 0 Gäste