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
* Objective: Regress salary based on age and sex.
* Then calculate Table of predicted salary for all ages between 20 & 65 and both sexes.
* Raynald Levesque 2001/03/13.

* Create dummy cases for the Table, with ages 20 to 65 and sexes 1 and 2.
INPUT PROGRAM. 
LOOP sex=1 TO 2.
LEAVE sex.
LOOP age=25 TO 65.
XSAVE OUTFILE='c:\\temp\\dummy cases.sav'.
END CASE.
END LOOP.
END LOOP.
END FILE.
END INPUT PROGRAM.
EXECUTE.

GET
  FILE='C:\\Program Files\\SPSS\\Employee data.sav'.
COMPUTE age=CTIME.DAYS(DATE.DMY(1,1,1998)- bdate)/365.25.
AUTORECODE VARIABLES gender /INTO sex.

* Add the dummy cases.
ADD FILES /FILE=*
 /FILE='C:\\Temp\\dummy cases.sav'
 /IN=source01.

* Do the regression excluding the dummy cases.
REGRESSION
  /SELECT= source01 EQ 0
  /MISSING LISTWISE
  /STATISTICS COEFF OUTS R ANOVA
  /CRITERIA=PIN(.05) POUT(.10)
  /NOORIGIN
  /DEPENDENT salary
  /METHOD=ENTER age sex
  /SAVE PRED .

* Keep only the table for ages 25 to 65 (ie the dummy cases).
SELECT IF source01=1.
MATCH FILES FILE=* /KEEP age sex pre_1.