1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
* I have a question concerning concatenating many string
* variables, I have 22 A1 string variables, say: 
* a1, a2, a3, ..., a22, I would like to calculate a string a(43): 
* a = a1-a2-a3-....-a22.

* How can I do it without writing:
  compute a = concat(a1, '-', a2, '-',..., a22).

* Posted to SPSSX-L by Raynald Levesque on 2004/03/02.

DATA LIST FREE /a1 TO a22 (22A1). 
BEGIN DATA
a b c d e f g h i j k l m n o p q r s t u v 
b c d e f g h i j k l m n o p q r s t u v w
END DATA.
STRING a(A43).
VECTOR a=a1 TO a22.
LOOP cnt=1 TO 21.
- COMPUTE a=CONCAT(RTRIM(a),a(cnt),"-") .
END LOOP.
- COMPUTE a=CONCAT(RTRIM(a),a(22)) .
EXECUTE.

VARIABLE WIDTH  a (43).