**************************************************. ** Question. **************************************************. I'm having a terrible headache with the following macro. --------------- Start ------------------------- define !compint (!pos !tokens(1) /!pos !tokens(1)). compute nobreak = 1. exec. aggregate outfile ='c:\\windows\\temp\\SPSS_002.tmp' /break= nobreak /minv1 = min(!1) /maxv1 = max(!1) /minv2 = min(!2) /maxv2 = max(!2). match files /file=* /table= 'c:\\windows\\temp\\SPSS_002.tmp' /by= nobreak. do if ($casenum=1). write outfile= 'c:\\windows\\temp\\minmax.sps' /'define min1() ' minv1 ' !enddefine.' /'define max1() ' maxv1 ' !enddefine.' /'define min2() ' minv2 ' !enddefine.' /'define max2() ' maxv2 ' !enddefine.'. end if. execute. include file='c:\\windows\\temp\\minmax.sps'. !do !i = min1 !to max1. !do !j = min2 !to max2. !let !varnam = !concat(i,!1,!2,!i,!j). numeric !varnam (f1). !let !lab = !quote(!concat(!1, ' cat-',!i,' & ',!2,' cat-',!j)). variable label !varnam !lab. !doend. exec. !doend. match files /file=* /drop= nobreak minv1 minv2 maxv1 maxv2. exec. !enddefine. data list free / x z. begin data 1 2 1 3 1 1 2 3 2 3 2 1 1 2 end data. !compint x z. ---------------- end macro/syntaxis ----------------------------------- The above macro try to create new variables with the combination of all pairs of categories for the variables X and Z. The result should be (new variables): ixz11 ixz12 ixz13 ixz21 ixz22 ixz23 But when I run the macro, an error appears (Error # 1. Command name: !ERROR_MACRO ...) What I'm doing wrong ? **************************************************. ** Solution posted to SPSSX-L on 2001/09/26 by Ray. **************************************************. It is always tricky to 1)write a macro, 2)include it and 3)use it, all in the SAME macro. * Splitting the job in 2 macros and using !EVAL when referring to the dynamically defined macros solved the problem. * Here is the revised syntax. SET MPRINT=no. *////////////////////. define !compint (!pos !tokens(1) /!pos !tokens(1)) compute nobreak = 1. aggregate outfile ='c:\\temp\\SPSS_002.tmp' /break= nobreak /minv1 = min(!1) /maxv1 = max(!1) /minv2 = min(!2) /maxv2 = max(!2). match files /file=* /table= 'c:\\temp\\SPSS_002.tmp' /by= nobreak. do if ($casenum=1). write outfile= 'c:\\temp\\minmax.sps' /'define min1() ' minv1 ' !enddefine.' /'define max1() ' maxv1 ' !enddefine.' /'define min2() ' minv2 ' !enddefine.' /'define max2() ' maxv2 ' !enddefine.'. end if. execute. include file='c:\\temp\\minmax.sps'. EXECUTE. !compin2 !1 !2. !enddefine. *////////////////////. *////////////////////. define !compin2(!pos=!tokens(1) /!pos=!tokens(1)) !do !i = !EVAL(min1) !to !EVAL(max1) !do !j = !EVAL(min2) !to !EVAL(max2) !let !varnam = !concat(i,!1,!2,!i,!j) numeric !varnam (f1). !let !lab = !quote(!concat(!1, ' cat-',!i,' & ',!2,' cat-',!j)) variable label !varnam !lab. !doend. exec. !doend. match files /file=* /drop= nobreak minv1 minv2 maxv1 maxv2. exec. !enddefine. *////////////////////. data list free / x z. begin data 1 2 5 8 1 1 2 3 2 3 2 1 1 2 end data. FORMATS x z (F1.0). SET MPRINT=yes. !compint x z.