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
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
* "multiple Mann-Whitney tests.SPS" 

*(Q) I have a problem with a macro:

DEFINE multi(depvar=!CHAREND ('/') /factor=!CHAREND ('/') /min=!CHAREND
('/') /max=!CMDEND ).
DO IF $CASENUM=1.
WRITE OUTFILE "c:\\temp\\multiman.sps"
/"NPAR TESTS".
LOOP #I=!min to !max-1.
LOOP #J=#I+1 to !max.
WRITE OUTFILE "c:\\temp\\multiman.sps"
/ "  /M-W= !depvar BY !factor (" #I #J ")".
END LOOP.
END LOOP.
WRITE OUTFILE "c:\\temp\\multiman.sps" /".".
END IF.
EXECUTE.
INCLUDE FILE="c:\\temp\\multiman.sps".
!ENDDEFINE.

Its purpose is to perform multiple Mann-Whitney tests after a
Kruskal-Wallis. As SPSS refuses to run statistical analyses inside any
loop, I have tried to use loops to write a syntax file (multiman.sps)
with the whole set of instructions and then run it with  INCLUDE.

* Example *.

DATA LIST LIST /actype (F8.0) glucose (F8.0).
BEGIN DATA
1 51
1 56
1 58
1 60
1 62
2 60
2 65
2 66
2 68
2 68
3 69
3 73
3 74
3 78
3 79
4 70
4 75
4 76
4 77
4 79
END DATA.

multi depvar=glucose /factor=actype /min=1 /max=4.

When I try to execute it, I get an error message saying that !depvar and
!factor are recognized only inside a macro.

So, the problem is:

The "multiman.sps" file looks like this:

NPAR TESTS
  /M-W= !depvar BY !factor (    1.00    2.00)
  /M-W= !depvar BY !factor (    1.00    3.00)
  /M-W= !depvar BY !factor (    1.00    4.00)
  /M-W= !depvar BY !factor (    2.00    3.00)
  /M-W= !depvar BY !factor (    2.00    4.00)
  /M-W= !depvar BY !factor (    3.00    4.00)
.

In order to make it work, I would like "multiman.sps" look like :

NPAR TESTS
  /M-W= glucose BY actype  (    1.00    2.00)
  /M-W= glucose BY actype  (    1.00    3.00)
  /M-W= glucose BY actype  (    1.00    4.00)
  /M-W= glucose BY actype  (    2.00    3.00)
  /M-W= glucose BY actype  (    2.00    4.00)
  /M-W= glucose BY actype  (    3.00    4.00)
.

How can I write the variable names in multiman.sps?



**************************************************.
*(A) Posted by rlevesque@videotron.ca to SPSSX-L on 2002/01/03.
**************************************************.

SET MPRINT=no.
*////////////////.
DEFINE multi(depvar=!CHAREND('/') /factor=!CHAREND('/') 
	/min=!CHAREND('/') /max=!CMDEND)
STRING depvar factor(A8).
COMPUTE depvar=!QUOTE(!depvar).
COMPUTE factor=!QUOTE(!factor).
DO IF $CASENUM=1.
WRITE OUTFILE "c:\\temp\\multiman.sps" /"NPAR TESTS".
LOOP #I=!min to !max-1.
LOOP #J=#I+1 to !max.
WRITE OUTFILE "c:\\temp\\multiman.sps"
 /"  /M-W= "depvar" BY "factor" (" #I #J ")".
END LOOP.
END LOOP.
WRITE OUTFILE "c:\\temp\\multiman.sps" /".".
END IF.
EXECUTE.
INCLUDE FILE="c:\\temp\\multiman.sps".
!ENDDEFINE.
*////////////////.

* Example *.

DATA LIST LIST /actype (F8.0) glucose (F8.0).
BEGIN DATA
1 51
1 56
1 58
1 60
1 62
2 60
2 65
2 66
2 68
2 68
3 69
3 73
3 74
3 78
3 79
4 70
4 75
4 76
4 77
4 79
END DATA.

SET MPRINT=yes.
multi depvar=glucose /factor=actype /min=1 /max=4.