利用SPSS Macro进行m次样本的抽样之后,将SPSS的OUTPUT转存为扩展名为.txt。
*STEP ONE: generating dataset with different distribution.
*----------------------------------------------------------------------------------.
INPUT PROGRAM.
+ LOOP #I =1 TO 5000.
+ COMPUTE NORM =rv.normal(100,15).
+ END CASE.
+ END LOOP.
+ END FILE.
END INPUT PROGRAM.
EXECUTE.
*STEP TWO: draw random samples from the given distributions.
View those distributions as the population we are interested in.
*------------------------------------------------------------------------------------------------------
*create a Macro facility to do the sampling process.
*-------------------------------------------------------------------------.
DEFINE ASMPL ( vars = !CHAREND ( '/' ) ).
!DO !i =1 !TO 1000.
temporary.
sample 100 from 5000.
descriptive var =!vars /statistics =mean.
write format !vars(f10.4).
!DOEND.
!ENDDEFINE.
*call the Macro program to do the sampling for those distributions.
ASMPL vars =norm /.
*STEP THREE: read output into SPSS file and check their distribution.
*------------------------------------------------------------------------------------------------------.
data list file ='E:\output.txt' records =13
/8 norm(22x,f9.4).
execute.
freq var =norm /format =notable /histogram =normal /statistics =all.
结果显示:
Data List will read 13 records from E:\output.txt
Variable Rec Start End Format
NORM 8 23 31 F9.4
>Warning # 1114
>Undefined error #1114 - Cannot open text file "C:\PROGRA~1\SPSS\en\windows\spss.err": No such file or directory
>Command line: 10087 Current case: 1 Current splitfile group: 1
>Field contents: '0 99.3194'
>Record number: 8 Starting column: 23 Record length: 8192
>Warning # 1114
>Undefined error #1114 - Cannot open text file "C:\PROGRA~1\SPSS\en\windows\spss.err": No such file or directory
>Command line: 10087 Current case: 2 Current splitfile group: 1
>Field contents: '0 103.196'
>Record number: 21 Starting column: 23 Record length: 8192
>Warning # 1114
>Undefined error #1114 - Cannot open text file "C:\PROGRA~1\SPSS\en\windows\spss.err": No such file or directory
>Command line: 10087 Current case: 3 Current splitfile group: 1
>Field contents: '0 101.214'
>Record number: 34 Starting column: 23 Record length: 8192
>Warning # 1114
>Undefined error #1114 - Cannot open text file "C:\PROGRA~1\SPSS\en\windows\spss.err": No such file or directory
>Command line: 10087 Current case: 4 Current splitfile group: 1
>Field contents: '0 98.3637'
>Record number: 47 Starting column: 23 Record length: 8192
>Warning # 1114
>Undefined error #1114 - Cannot open text file "C:\PROGRA~1\SPSS\en\windows\spss.err": No such file or directory
>Command line: 10087 Current case: 5 Current splitfile group: 1
>Field contents: '0 100.067'
>Record number: 60 Starting column: 23 Record length: 8192
>Warning # 1114
>Undefined error #1114 - Cannot open text file "C:\PROGRA~1\SPSS\en\windows\spss.err": No such file or directory
>Command line: 10087 Current case: 6 Current splitfile group: 1
>Field contents: '0 100.032'
>Record number: 73 Starting column: 23 Record length: 8192
>Warning # 1114
>Undefined error #1114 - Cannot open text file "C:\PROGRA~1\SPSS\en\windows\spss.err": No such file or directory
>Command line: 10087 Current case: 7 Current splitfile group: 1
>Field contents: '0 99.9544'
>Record number: 86 Starting column: 23 Record length: 8192
>Warning # 1114
>Undefined error #1114 - Cannot open text file "C:\PROGRA~1\SPSS\en\windows\spss.err": No such file or directory
>Command line: 10087 Current case: 8 Current splitfile group: 1
>Field contents: '0 99.7957'
>Record number: 99 Starting column: 23 Record length: 8192
>Warning # 1114
>Undefined error #1114 - Cannot open text file "C:\PROGRA~1\SPSS\en\windows\spss.err": No such file or directory
>Command line: 10087 Current case: 9 Current splitfile group: 1
>Field contents: '0 99.8836'
>Record number: 112 Starting column: 23 Record length: 8192
>Warning # 1114
>Undefined error #1114 - Cannot open text file "C:\PROGRA~1\SPSS\en\windows\spss.err": No such file or directory
>Command line: 10087 Current case: 10 Current splitfile group: 1
>Field contents: '0 97.8752'
>Record number: 125 Starting column: 23 Record length: 8192
>Warning # 92
>Undefined error #92 - Cannot open text file "C:\PROGRA~1\SPSS\en\windows\spss.err": No such file or directory