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
*(Q) How can I generate the following using macro:
if any(f1,1) c1 = 1.
if any(f1,f2,1) c2 = 1.
if any(f1,f2,f3,1) c3 = 1.
[repeated for 29 f variables]
if any(f1,f2,f3,f4,f5,.......f29,1) c29 = 1.
Where the the number of f (29 in this case) is feed to the macro.

*(A) Posted to SPSSX-L list on 2004/07/19 by Raynald Levesque.
DATA LIST LIST /id.
BEGIN DATA
1
END DATA.

NUMERIC f1 TO f29.

*////////////////////.
DEFINE !any(nb=!TOKENS(1))

!DO !c = 1 !TO  !nb
IF ANY (!DO !i=1 !TO !c !CONCAT('f',!i), !DOEND 1) !CONCAT('c',!c)=1.
!DOEND 
!ENDDEFINE.
*////////////////////.

SET MPRINT=yes.
!any nb=4.

!any nb=29.