SPSS Statistics

SPSS Statistics

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

 View Only
  • 1.  SAVE in place vs. SAVE OUTFILE = 'my/path/file.sav'

    Posted Sat September 03, 2022 06:11 AM
    Is there a way to simply save an SPSS dataset (previously opened with either GET FILE or using the GUI)? Just save it to the location where it already exists on disk, without specifying a path?

    The following syntax of course doesn’t work, but I hope you get the idea.

    GET FILE '/my/Path/data.sav'.
    * Transformations go here.
    SAVE OUTFILE. /* no file spec, just to the location it was opened from.


    Frank Watzl
    #SPSSStatistics


  • 2.  RE: SAVE in place vs. SAVE OUTFILE = 'my/path/file.sav'

    Posted Tue September 06, 2022 01:31 PM

    Hi Frank,

    Whether you write the SAVE command syntax yourself or you use the IBM SPSS Statistics graphic user interface, the result is the same.  The backend will attempt to process a SAVE command.  The SAVE command has required OUTFILE specification.

    See https://www.ibm.com/docs/en/spss-statistics/28.0.0?topic=save-outfile-subcommand-command



    ------------------------------
    David Dwyer
    SPSS Technical Support
    IBM Software
    ------------------------------



  • 3.  RE: SAVE in place vs. SAVE OUTFILE = 'my/path/file.sav'

    Posted Tue September 06, 2022 03:13 PM
    Well, there is a toolbar button that does exactly that without any additional specification.

    --





  • 4.  RE: SAVE in place vs. SAVE OUTFILE = 'my/path/file.sav'

    Posted Tue September 06, 2022 03:25 PM
    The toolbar button appends the required OUTFILE spec. To see that, set PRINTBACK on.

    It wouldn't be out of the question to make OUTFILE assume a default (the original path/file location), but obviously that's a change to the existing code.

    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------



  • 5.  RE: SAVE in place vs. SAVE OUTFILE = 'my/path/file.sav'

    Posted Tue September 06, 2022 03:47 PM
    Edited by System Admin Fri January 20, 2023 04:31 PM

    In the meantime I found that this does the trick with a dataset previously opened and modified in the GUI:

    BEGIN PROGRAM PYTHON3.
    import SpssClient
    SpssClient.StartClient()
    ActiveDataDoc = SpssClient.GetActiveDataDoc()
    DocPath = ActiveDataDoc.GetDocumentPath()
    ActiveDataDoc.SaveAs(DocPath)
    END PROGRAM.

    If the dataset was opened with GET FILE, the document path is known anyway and can simply be repeated in the SAVE OUTFILE statement. A default argument would still be easier to use.

    My use case is solved. Thank you very much for the discussion.


    ------------------------------
    Frank Watzl
    ------------------------------



  • 6.  RE: SAVE in place vs. SAVE OUTFILE = 'my/path/file.sav'

    Posted Tue September 06, 2022 04:02 PM
    That works.  Of course, it will fail if there is no path known.  You might want to call StopClient at the end of that program.

    There is also this rather odd note on the GetDocumentPath api.

    Note: If you reopen a data file that is currently open, the GetDocumentPath method will return the
    empty string when called on the SpssDataDoc object associated with the reopened instance of the file.






  • 7.  RE: SAVE in place vs. SAVE OUTFILE = 'my/path/file.sav'

    Posted Tue September 06, 2022 04:42 PM
    Thanks for this hint. I will either have to avoid this case or catch errors. For my current application this is fortunately not necessary.