It is not possible to (directly) do arithmetic with macro variables.
For instance, given the following 2 macro statements:
!LET !a=1.
!LET !b=2.
the following is not a valid command:
!LET !c=!a + !b.
The following is an indirect method of obtaining the sum of !a and !b.
!LET !c=!LENGTH(!CONCAT(!BLANK(!a),!BLANK(!b)).
This is not a very friendly method... Try to do a division (or calculate the log of !b) with a similar method!
* Suppose we need the macro variable !myvar to take on "complex" values such as the ln(2), ln(3) and ln(4).
Any number of values and any other formulas could be handled, but I will use these 3 to illustrate the method.
The trick is to have SPSS calculate the numeric values and write the syntax which will be subsequently run.
SET MPRINT=yes.
*///////////////////////////////////.
DEFINE !doit(nbval=!TOKENS(1))
INPUT PROGRAM.
LOOP cnt=1 TO !nbval.
COMPUTE myval=LN(cnt).
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
* Next line assumes you need 5 digits.
FORMAT myval(F8.5).
* Define the macro variable.
DO IF cnt=1.
WRITE OUTFILE='c:\temp\macro var.sps' /"DEFINE !values()"/myval.
ELSE IF cnt