SPSS Statistics

SPSS Statistics

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

 View Only
Expand all | Collapse all

How to "Get Data" with SPSS file name + current date

  • 1.  How to "Get Data" with SPSS file name + current date

    Posted Tue July 21, 2020 06:57 PM

    Hello,

    I currently save my SPSS data file daily with the following syntax to include date using the following code:

    begin program.

    import time, spss

    spss.SetMacroValue("!timestamp", "'" + time.strftime("%Y-%m-%d") + "'")

    end program.

    file handle mydir /name = "d:/temp".

    save outfile = "C:\Coronavirus\Disease Export_" + !timestamp + ".sav".

    After I save it I run a few different analysis on the data that ends with a different data set.

    I would now like to add code to pull the original data saved with the current date (Disease Export _Date) without closing out and starting over with: "file - open - Data...."

    I think I can use the "Get Data" command, but how do I tell SPSS I want the file with the current date as this will be done daily?






    #SPSSStatistics
    #Support
    #SupportMigration


  • 2.  RE: How to "Get Data" with SPSS file name + current date

    Posted Wed July 22, 2020 03:40 PM

    Hi Support Member​ 

    Presuming your code above works, and that you correctly set !timestamp to the desired value:

    GET FILE = "C:\Coronavirus\Disease Export_" + !timestamp + ".sav".

     

    I hope this helps!

    Support Member​ (IBM)

     






    #SPSSStatistics
    #Support
    #SupportMigration


  • 3.  RE: How to "Get Data" with SPSS file name + current date

    Posted Wed July 22, 2020 07:05 PM