Search code examples
spss

SPSS Get working directory


I am using SPSS 19 und would like to get the current working directory to use the INSERT command, to call additional syntax files. Does somebody know how to do it? There seems to be a Python command (SpssClient.GetCurrentDirectory()) but that returns a gibberish error code (I love this pile of crap called SPSS....)


Solution

  • Rather than using the scripting API's, you can use the programmabilty API's like this.

    begin program.  
    import spss, spssaux  
    workingdir = spssaux.getShow("DIRECTORY")  
    spss.Submit("""FILE HANDLE cwd /NAME="%s".""" % workingdir)  
    end program.  
    

    This defines a file handle named cwd.

    Note also that INSERT has a CD keyword that changes the backend working directory to whatever location is specified in FILE.

    HTH, Jon Peck