您可以輕鬆地重複在SPSS統計使用宏像下面的文件:
***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.