LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2006)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 31 May 2006 10:09:11 +0100
Reply-To:   "Allan Reese (Cefas)" <allan.reese@cefas.co.uk>
Sender:   "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:   "Allan Reese (Cefas)" <allan.reese@cefas.co.uk>
Subject:   Re: INPUT PROGRAM paradox
Comments:   cc: Richard Ristow <wrristow@mindspring.com>
Content-Type:   text/plain; charset="iso-8859-1"

The answer lies in the Help/Syntax documentation ie, look up the description of LOOP/End Loop and you will find the preferred answer to the original problem.

Essentially, the offered solution is trying to use A, B and C for two distinct purposes: as variables in the new dataset and as counters in the program. I had assumed that loop counters were by definition temporary variables, but the documentation example shows not: you have to make this explicit by naming them #varname. The documentation example is

* Example of nested loops: compute every possible combination of values for each variable. INPUT PROGRAM. -LOOP #I=1 TO 4. /* LOOP TO NUMBER OF VALUES FOR I + LOOP #J=1 TO 3. /* LOOP TO NUMBER OF VALUES FOR J @ LOOP #K=1 TO 4. /* LOOP TO NUMBER OF VALUES FOR K @ COMPUTE I=#I. @ COMPUTE J=#J. @ COMPUTE K=#K. @ END CASE. @ END LOOP. + END LOOP. -END LOOP. END FILE. END INPUT PROGRAM. LIST.

And the explanation of the paradox is that the "END LOOP" for C in Richard's version initialized all the variables so that on each turn of an inner loop only the inner variables had values. Again, extract from the documentation:

This example does not require a LEAVE command because the iteration variables are scratch variables. If the iteration variables were I, J, and K, LEAVE would be required because the variables would be reinitialized after each END CASE command.

Computers do exactly what you tell them, not what you want.

*********************************************************************************** This email and any attachments are intended for the named recipient only. Its unauthorised use, distribution, disclosure, storage or copying is not permitted. If you have received it in error, please destroy all copies and notify the sender. In messages of a non-business nature, the views and opinions expressed are the author's own and do not necessarily reflect those of the organisation from which it is sent. All emails may be subject to monitoring. ***********************************************************************************


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