LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (April 2004)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 22 Apr 2004 09:55:23 +0200
Reply-To:     Spousta Jan <JSpousta@CSAS.CZ>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Spousta Jan <JSpousta@CSAS.CZ>
Subject:      Re: loop in macros
Comments: To: Richard Ristow <>
Content-Type: text/plain; charset="iso-8859-2"

Dear Richard,

I agree with you, that Raynalds solution is rather complicated. But I think that we can simplify it even without new functions in macros (although I would be _very_ pleased if the macro language would have new features, e.g. standard arithmetics).

The simpler and less tricky solution for parallel processing of two (or more) lists in the SPSS macros should use functions !tail and !head. For example:

get file='c:\program files\spss\employee data.sav'.

define newsort (!pos = !cha ('/') / !pos = !cmd). !let !adad = !2. !let !command = 'SORT CASES BY '. !do !column !in (!1). !let !he = !head(!adad). !let !adad = !tail(!adad). !let !command = !concat(!command,!column," (",!he,") "). !doend. echo !quote(!command) . !command . !enddefine.

newsort gender jobcat salary / a d a .



-----Original Message----- From: Richard Ristow [] Sent: Wednesday, April 21, 2004 10:41 PM To: SPSSX-L@LISTSERV.UGA.EDU Subject: Re: loop in macros

Raynald Levesque's code for this is a tremendous job, but my reaction is, OUCH! What a set of tricks to get around SPSS limitations! The goal, of course, is parallel processing of the lists in the two arguments, as DO REPEAT/END REPEAT does with multiple variable or value lists; and this is a fairly common need. This really needs a macro-language extension. One possibility is extending !DO...!IN to do parallel list processing like DO REPEAT: something like (this is *NOT* currently valid macro code),

!DO !i !IN (!var1) /!j !IN (!sort) <macro statements> !DOEND

where this !var1 and !var2 lists are processed in parallel. Or an explicit way of indexing the Nth element from a list, so *that* doesn't need an inner !DO loop -- something like

!LET !j = !WORDOF(!SORT,n)

where 'n' is a macro expression evaluating to an integer. As frequently stated, integer arithmetic in the macro language would make a BIG difference, though that isn't crucial for this application; the existing

!DO !n = 1 to !FINISH

would work, if there were some way to find the stopping value -- say,


Raynald's work-around is wonderful, but I'd say it's a worse indictment of the macro language than any polemic could be.

Back to: Top of message | Previous page | Main SPSSX-L page