English 中文(简体)
Specifying relative paths in SPSS 18
原标题:

In SPSS 11 it was possible to specify relative paths. Example:

FILE HANDLE myfile= ....datacurrent.txt  /LRECL=533.
DATA LIST FILE=myfile /
...

This worked because apparently, SPSS 11 set the working folder to the path where the source .SPS file is saved. It seems that SPSS 18 always sets it s working folder to the installation folder of SPSS itself. Which is not at all the same thing.

Is there an option to change this behaviour? Or am I stuck with changing everything to absolute filenames?

最佳回答

Instead of a relative path, you could define a directory path and use it inside other file handle declarations to save typing:

FILE HANDLE directoryPath /NAME= C:DirectoryPath .
FILE HANDLE myFile /NAME= directoryPath/fileName.xyz .
GET FILE= myFile .

This will get the file: C:DirectoryPathfileName.xyz.

The direction of the slashes may be important.

(Works in version 17)

问题回答

If you use the INSERT command to run an sps file, it has an option to change the working directory to that location.

You could use the HOST command to SUBST a drive letter (on PCs) and reference everything through that.

You could define a FILE HANDLE to the common root location and use that in file references.

You could use Python programmability to find the path to the active syntax window and issue an SPSS CD command to set the backend working directory appropriately.

HTH, Jon Peck

With Python, you can get the full path of the current syntax window (or any other one) and get its path. Using that you can issue an SPSS cd command to change the backend working directory accordingly.

If you define an environment variable, though, you can use that in file specifications within SPSS.

p.s. SPSS has an extensive set of apis and helper modules for Python (as well as for R and .NET languages). You can get information about this from SPSS Developer Central, www.spss.com/devcentral. All the language extensions are free once you have the base SPSS Statistics product.

Regards, Jon Peck

Or use "CD" command to change your default working directory. See also:

http://www.spss-tutorials.com/change-your-working-directory/

For example, if your default directory is C:project, then GET FILE datadata_file.sav . will open data_file.sav from C:projectdata.

And then, a few minutes later, i came across this little python script from jignesh-sutar (see here: SPSS syntax - use path of the file.

With his python code you can use the path of the syntax file as starting point for all the paths in your syntax.





相关问题
VS 2008 : How to publish with out DLLs?

I have developed a web application in Visual Studio 2008 and want to publish it in to the production server. I see a publish option there.But its producing files with DLL. I dont want to publish only ...

Apache: Deploying a new site to the server

I have a site currently live on a domain. I would like to switch it to a new site, that is currently in a password protected sub directory on this server. I have a "Site Maintenance in Progress" page....

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Pylons deployment questions

I m a beginner with Pylons and I ve mostly developed on my localhost using the built-in web server. I think it s time to start deployment for my personal blog, I have a Debian Lenny server with ...

Do I want Publish or Release Build in VB.net?

I wrote a little (like 40 lines little) Winforms application with VB.net in Visual Studio 2010. Now I ve released the code as a Google Code project. It s easy for a developer to get the source but I d ...

Need advice on my PHP development solution

Here is how our current php development solution is set up: Each developer work on their local machine. Each developer commit their change to a common SVN server (intranet). A commit hook upload the ...

loading from JAR files during deployment vs development

when i am loading some data into my java program, i usually use FileInputStream. however i deploy the program as a jar file and webstart, so i have to use getRessource() or getRessourceAsStream() to ...

热门标签