Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macros SPSS宏在多个数据文件中运行聚合命令_Macros_Spss - Fatal编程技术网

Macros SPSS宏在多个数据文件中运行聚合命令

Macros SPSS宏在多个数据文件中运行聚合命令,macros,spss,Macros,Spss,我想在多个SPSS数据文件上运行以下代码(而不是打开每个文件并分别运行代码等),但不确定如何编写相应的宏。非常感谢你的帮助。谢谢 sort cases by ID(A) TEST_ID(A). If RESULT='Positive' RESULTS=1. If RESULT='Negative' RESULTS=0. AGGREGATE OUTFILE='C:\Desktop\\072013-aggregated.sav' /PRESORTED /BREAK=ID /CLINIC=FI

我想在多个SPSS数据文件上运行以下代码(而不是打开每个文件并分别运行代码等),但不确定如何编写相应的宏。非常感谢你的帮助。谢谢

sort cases by ID(A) TEST_ID(A).


If RESULT='Positive' RESULTS=1.
If RESULT='Negative' RESULTS=0.


AGGREGATE OUTFILE='C:\Desktop\\072013-aggregated.sav'
/PRESORTED
/BREAK=ID
/CLINIC=FIRST(CLINIC)
/SEX=FIRST(SEX)
/DOB=FIRST(DOB).

你不能用宏来做这类事情,但是你可以用SPSSINC进程文件扩展名命令来做。这需要(免费的)Python软件包。较新版本的统计信息在Essentials中包含此命令。如果它不在你的版本中,你可以下载它。该命令包括传统的SPSS语法和对话框界面


Python Essentials和各种扩展命令可通过SPSS社区网站www.ibm.com/developerworks/spssdevcentral获得。

我不同意@JKP。可以使用宏执行此操作


请考虑其他选择。尝试将所有文件添加到一个文件中(添加文件命令)。在子命令中使用创建文件指示器(请参阅添加文件文档)。仅对组合文件运行一次命令。

您可以使用宏轻松地迭代文件,如下面的SPSS statistics中所示:

***Defining the path.

DEFINE !Path() 'C:\Documents and Settings\admin\Desktop\' 
!ENDDEFINE.
***You can seperate output paths from input paths and make another macro like above.

DEFINE !agg_loc (!POS=!CMDEND) .
!DO !var !IN (!1)
GET FILE=!quote(!CONCAT(!unquote(!eval(!Path)),!var,".sav")).
DATASET NAME !var.
DATASET ACTIVATE !var.

sort cases by ID(A) TEST_ID(A).
If RESULT='Positive' RESULTS=1.
If RESULT='Negative' RESULTS=0.

AGGREGATE OUTFILE=!quote(!CONCAT(!unquote(!eval(!Path)),!var,"_output_",".sav"))
    /PRESORTED
    /BREAK=ID
    /CLINIC=FIRST(CLINIC)
    /SEX=FIRST(SEX)
    /DOB=FIRST(DOB).

!DOEND.
EXECUTE.
!ENDDEFINE.

***Calling the macro.

!agg_loc dsn_abc.  
!agg_loc dsn_xyz.

**Here dsn_abc,dsn_xyz are file names present at desktop , you can add more file names similarly if there are more files to be read and processed

**The outcome will present at desktop appended with _output_  , e.g dsn_abc_output_.sav is output for first processing and so on.