!do-!doend question

Posted by Guido Schiffhorst on
URL: http://spssx-discussion.165.s1.nabble.com/do-doend-question-tp5740533.html

Hi,

 

The following „macro_wo_loop“ brings "Z" to the screen, the other one („macro_loop“) with an additional loop around it presents "*" and some error messages I can't assign.

 

Is there a working way to call another macro inside a !do-!doend loop and pass an argument?

 

Best

Guido

 

--

output close all.

dataset close all.

new file.

 

DATA LIST LIST/ X Y Z (3 A1).

BEGIN DATA

    F F A

    R B B

END DATA.

save outfile = 'c:\temp\d.sav'.

 

dataset close all.

new file.

 

define macro1 (pop !tokens(1))

echo !quote(!pop).

!enddefine.

 

define macro_loop (v !tokens(1))

    !do !i = 1 !to 1

        get file = 'c:\temp\d.sav'.

        do if $casenum = 1.

            write outfile = 'c:\temp\foo.sps'

            /'macro1 pop =' !quote(!v) '.'.

        end if.

        exe.

        insert file = 'c:\temp\foo.sps'.

    !doend

!enddefine.

 

define macro_wo_loop (v !tokens(1))

    get file = 'c:\temp\d.sav'.

    do if $casenum = 1.

        write outfile = 'c:\temp\foo.sps'

        /'macro1 pop =' !quote(!v) '.'.

    end if.

    exe.

    insert file = 'c:\temp\foo.sps'.

!enddefine.

 

 

macro_wo_loop v = Z.

 

macro_loop v = Z.

 

 

 

 

 

 

 

 

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD