Simplifing Via Syntax

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Simplifing Via Syntax

Juan Pablo Sandoval
Hi:

I'm runing a long line of commnads to check a frequencies for like so:

Freq v001, and then a Mult Response for v002 and v003

then...

Freq v004, and Mult Response form v005 and v006...

Is there a way to simplify this via a macro so instead to have a long lines
of sintax doing it via a macro???

Regards,

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Simplifing Via Syntax

Albert-Jan Roskam
Hi Juan,

This is not so easy with macro language since one
cannot perform arithmatic with the macro facility.
There is one --very ugly-- macro solution which
involves counting !blanks, but I'll ignore that
because Python offers a much more elegant, and simpler
solution:

set mprint = on.
begin program.
import spss
for i in range (1, 100, 3):
        spss.Submit(r"""fre v%03d.
                        means v%03d.
                        means v%03d.
                        """ %(i, i + 1, i + 2))
end program.

This allows variables v001-v100 to be processed. The
code %03d refers to the index value that is
left-padded with zeros. I used 'means'  because I
don't know the syntax for multiple response, but of
course you can easily replace that.

Cheers!! (and have a nice weekend!)
Albert-Jan



      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

=====================
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