How to source a syntax file from another syntax file in SPSS?

我怕爱的太早我们不能终老 提交于 2019-12-07 12:19:25

问题


In R there is the source function where you can source an R script from another R script. I want to be able to do the same in SPSS.

How can I source an SPSS syntax file from another SPSS syntax file?


回答1:


Updated Following @AndyW's comments.

There is the INSERT and INCLUDE commands. INSERT is newer and more versatile than INCLUDE. See documentation on INSERT here.

The following is the basic syntax template:

INSERT  FILE='file specification'
       [SYNTAX = {INTERACTIVE*}]
                 {BATCH       }
       [ERROR = {CONTINUE*}]
                {STOP     }
       [CD = {NO*}]
             {YES}
       [ENCODING = 'encoding specification']

Thus, the following command can be placed in an SPSS syntax file

INSERT FILE='foo.sps'. 

and it would import foo.sps syntax file. By default, syntax must follow the rules of interactive mode, and the code wont stop on an error.

To avoid having to specify the full path to the file, the working directory can be specified as an argument in the INSERT statement or with a separate CD command. E.g.,

CD '/user/jimbo/long/path/to/project'

Another option is to use FILE HANDLE.

For more information see the SPSS Syntax Reference (available here as a large PDF file).



来源:https://stackoverflow.com/questions/13149117/how-to-source-a-syntax-file-from-another-syntax-file-in-spss

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!