1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
***oms_bootstrapping.sps***.
***if c:\\temp is not a valid drive\\path, replace all instances of c:\\temp
   with a valid drive\\path.

PRESERVE.
SET TVARS NAMES.

*first OMS command just suppresses Viewer output.
OMS /DESTINATION VIEWER=NO /TAG='suppressall'.

*select regression coefficients tables and write to data file.
OMS /SELECT TABLES
    /IF COMMANDS=['Regression'] SUBTYPES=['Coefficients']
    /DESTINATION FORMAT=SAV OUTFILE='c:\\temp\\temp.sav'
   /COLUMNS DIMNAMES=[ 'Variables'  'Statistics']
   /TAG='reg_coeff'.

*define a macro to draw samples with replacement and 
 run Regression commands.
DEFINE regression_bootstrap (samples=!TOKENS(1)
                                           /depvar=!TOKENS(1)
                                           /indvars=!CMDEND)
                                          
COMPUTE dummyvar=1.
AGGREGATE
  /OUTFILE='c:\\temp\\aggrtemp.sav'
  /BREAK=dummyvar
  /filesize=N.
MATCH FILES FILE=* /TABLE='c:\\temp\\aggrtemp.sav'
  /BY dummyvar.
!DO !other=1 !TO !samples
SET SEED RANDOM.
WEIGHT OFF.
FILTER OFF.
DO IF $casenum=1.
- COMPUTE #samplesize=filesize.
- COMPUTE #filesize=filesize.
END IF.
DO IF (#samplesize>0 and #filesize>0).
- COMPUTE sampleWeight=rv.binom(#samplesize, 1/#filesize).
- COMPUTE #samplesize=#samplesize-sampleWeight.
- COMPUTE #filesize=#filesize-1.
ELSE.
- COMPUTE sampleWeight=0.
END IF.
WEIGHT BY sampleWeight.
FILTER BY sampleWeight.
REGRESSION
  /STATISTICS COEFF
  /DEPENDENT !depvar
  /METHOD=ENTER !indvars.
!DOEND
!ENDDEFINE.

***insert any valid path\\data file name***.
GET FILE='c:\\Program Files\\SPSS\\Employee data.sav'.

***Call the macro, and specify number of samples,
   dependent variable, and independent variables.
regression_bootstrap 
   samples=100
   depvar=salary 
   indvars=salbegin  jobtime .

OMSEND.

GET FILE 'c:\\temp\\temp.sav'.

FREQUENCIES
  VARIABLES=salbegin_B salbegin_Beta jobtime_B jobtime_Beta
  /FORMAT NOTABLE
  /PERCENTILES= 2.5 97.5
  /HISTOGRAM NORMAL.

RESTORE.