SPSS Statistics

SPSS Statistics

Your hub for statistical analysis, data management, and data documentation. Connect, learn, and share with your peers! 

 View Only
  • 1.  Merging Multiple Files

    Posted Mon March 03, 2025 10:55 AM

    Can I use syntax to merge multiple files at the same time? I have up to 20 excel files that need to be merged and brought into SPSS - there is a unique patient ID for each case in each file. Thank you!



    ------------------------------
    Nicole Rodriguez
    ------------------------------


  • 2.  RE: Merging Multiple Files

    Posted Mon March 03, 2025 11:13 AM
    Within spss you'll need to use syntax & write them in one at time. You could also open a python block & use glob/pandas.

    Sent from my iPhone




  • 3.  RE: Merging Multiple Files

    Posted Mon March 03, 2025 11:36 AM

    Hi Nicole,

     

    It depends a bit on what you mean by "merging" files. If you want to "stack" one file on top of another to make one master file, then you can use ADD FILES syntax. In this scenario, you might have multiple records for the same patient ID, and you would need to analyze by time period or something similar.

     

    If you are appending new variables from multiple files to a master file, That would require a different approach. In that scenario, you would use either MATCH FILES or UPDATE.

     

    Cheers,

     

    Bob

     

     


    A picture containing stop  Description automatically generated

    Robert W. Walker

    CEO & Founder

    23 S. Main St.·  Norwalk, CT 06854

    Tel. +1.203.255.0505

    https://usemotion.com/meet/rwwalker/meeting

     

     

     






  • 4.  RE: Merging Multiple Files

    Posted Mon March 03, 2025 12:54 PM
      You can merge up to 50 data files at a time with either ADD FILES or MATCH FILES, but the files have to SAV files or open datasets.

    There is an extension command, SPSSINC PROCESS FILES, that you could use to convert all the Excel files in a directory into SAV files.  The syntax help for the file actually has an example of doing exactly that.  You would need to read through most of that help to get the full picture.

    You can see the syntax help for this command here
    file:///C:/Users/jkpec/AppData/Roaming/IBM/SPSS%20Statistics/one/extensions/SPSSINC_PROCESS_FILES/markdown.html

    You need to install this command via Extensions > Extension Hub in order to use it.


    --