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
* QUESTION: .
* My variables of interest go from y1 to y800 and x1 to x3. 
* I want to do 800 regressions: regress var using x1, x2 and x3 where
* var is successively equal to y1, y2, ...y800.
* Regression is not allowed in a loop. Is there a way around?

* ANSWER by rlevesque@videotron.ca 2002/04/16.

* Create a dummy file for illustration purposes.
NEW FILE.
INPUT PROGRAM.
VECTOR y(20F8.0).
LOOP v1=1 TO 100.
COMPUTE x1=UNIFORM(5).
COMPUTE x2=UNIFORM(5).
COMPUTE x3=UNIFORM(5).
LOOP #cnt=1 TO 20.
COMPUTE y(#cnt)=UNIFORM(10).
END LOOP.
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
EXECUTE.

SET MPRINT=no.
* define a macro to do the job.
*/////////////////////////////////.
DEFINE !regloop(nby=!TOKENS(1)).
!DO !cnt=1 !TO !nby.
REGRESSION
    /STATISTICS COEFF OUTS R ANOVA
    /DEPENDENT !CONCAT('y',!cnt)
    /METHOD=ENTER x1 x2 x3 .
!DOEND.
!ENDDEFINE.
*/////////////////////////////////.

SET MPRINT=yes.
*Call macro (replace 20 by 800 if you have y1 to y800).
!regloop nby=20.