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
*(Q)  I have a table that looks like

 id, var1
 1, AAA
 2, BBB
 3, AAA
 4, BBB
 5, CCC
 6, AAA
 7, FFF
 etc...
 and I would like to run a code for all the instances of var1, using
 the values of var1 to call a Macro, such as
 
 !Macro1 var="AAA"
 !Macro1 var="BBB"
 etc...

*(A) Posted to newsgroup by Raynald Levesque on 2003/04/11.

DATA LIST LIST /id (F3) var1(A3).
BEGIN DATA
1 AAA
2 BBB
3 AAA
4 BBB
5 CCC
6 AAA
7 FFF
END DATA.

AGGREGATE OUTFILE=*
	/BREAK=var1
	/notused=N.

WRITE OUTFILE='c:\\temp\\call macro.sps'
	/'!macro1 var="'var1'".'.
EXECUTE.
INCLUDE 'c:\\temp\\call macro.sps'.


*** This is the content of "call macro.sps"
!macro1 var="AAA".
!macro1 var="BBB".
!macro1 var="CCC".
!macro1 var="FFF".