Discussion:
How to exit an unsuccesful LOOP?
(too old to reply)
Karovaldas
2006-05-23 03:16:25 UTC
Permalink
I've been writing loops and making mistakes. Unfortunately, after I
make a mistake that results in an unclosed LOOP, I have to close and
re-open the data file because it becomes locked. The status line reads
"Transformations Pending", but running transformations only yield more
error messages telling me that a DO or a LOOP is not closed.

Is there a way to tell the program to ignore the error and discard the
pending transformatoins?

Also, I am not entirely sure what's wrong with the LOOP itself. Below
is a part of it that sometimes works and sometimes does not. I used a
"DO IF ... ELSE IF" sequence and eventualy had to resort to single DO
IF within a loop. Can LOOP handle multiple ELSE IF structure?

VECTOR D=Dble3 TO Dble13 .
LOOP #I = 1 TO 11 .
- DO IF Stage = 4 .
+ DO IF RTime = #I+2 .
+ COMP D(#I) = 1 .
+ END IF .
- END IF .
END LOOP
EXE .

Thanks,
Haris
Antoon
2006-05-23 09:24:34 UTC
Permalink
Post by Karovaldas
I've been writing loops and making mistakes. Unfortunately, after I
make a mistake that results in an unclosed LOOP, I have to close and
re-open the data file because it becomes locked. The status line reads
"Transformations Pending", but running transformations only yield more
error messages telling me that a DO or a LOOP is not closed.
Is there a way to tell the program to ignore the error and discard the
pending transformatoins?
Also, I am not entirely sure what's wrong with the LOOP itself. Below
is a part of it that sometimes works and sometimes does not. I used a
"DO IF ... ELSE IF" sequence and eventualy had to resort to single DO
IF within a loop. Can LOOP handle multiple ELSE IF structure?
VECTOR D=Dble3 TO Dble13 .
LOOP #I = 1 TO 11 .
- DO IF Stage = 4 .
+ DO IF RTime = #I+2 .
+ COMP D(#I) = 1 .
+ END IF .
- END IF .
END LOOP
EXE .
Thanks,
Haris
Have you tried to stop the processor in the file menu or by pressing
Control - period (I mean the control key and the punctuation mark you put at
the end of sentences) ?

Antoon
Karovaldas
2006-05-23 19:03:31 UTC
Permalink
That's the thing, Antoon, the processor is not running. It keeps the
open LOOP in memory somewhere and I can't close it. Without closing
it, nothing else works.
Richard Ulrich
2006-05-24 00:22:30 UTC
Permalink
Post by Karovaldas
That's the thing, Antoon, the processor is not running. It keeps the
open LOOP in memory somewhere and I can't close it. Without closing
it, nothing else works.
You say "nothing else works."
What are the symptoms? - error messages, or whatever.
--
Rich Ulrich, ***@pitt.edu
http://www.pitt.edu/~wpilib/index.html
Bruce Weaver
2006-05-23 20:06:53 UTC
Permalink
Post by Karovaldas
I've been writing loops and making mistakes. Unfortunately, after I
make a mistake that results in an unclosed LOOP, I have to close and
re-open the data file because it becomes locked. The status line reads
"Transformations Pending", but running transformations only yield more
error messages telling me that a DO or a LOOP is not closed.
Is there a way to tell the program to ignore the error and discard the
pending transformatoins?
Also, I am not entirely sure what's wrong with the LOOP itself. Below
is a part of it that sometimes works and sometimes does not. I used a
"DO IF ... ELSE IF" sequence and eventualy had to resort to single DO
IF within a loop. Can LOOP handle multiple ELSE IF structure?
VECTOR D=Dble3 TO Dble13 .
LOOP #I = 1 TO 11 .
- DO IF Stage = 4 .
+ DO IF RTime = #I+2 .
+ COMP D(#I) = 1 .
+ END IF .
- END IF .
END LOOP
EXE .
Thanks,
Haris
That code looks like it should run. But why not use a single IF like this?

VECTOR D=Dble3 TO Dble13 .
LOOP #I = 1 TO 11 .
- IF (Stage = 4) and (RTime = (#I+2)) D(#I) = 1 .
END LOOP
EXE .
--
Bruce Weaver
***@lakeheadu.ca
www.angelfire.com/wv/bwhomedir
Karovaldas
2006-05-23 21:24:01 UTC
Permalink
Thanks for a simplifying suggestion, Bruce; however, I am still stuck
in the LOOP. Even if this one will work magically, I am sure I'll make
mistakes other places and then I have to exit the file and reopen it in
order to continue work.
Russ Sanders
2006-05-24 06:45:04 UTC
Permalink
Welcome to SPSS.
I do not believe there is any other way then "exit the file and reopen it."

Try the following (v11.5, not sure about newer versions)
define ...

set mprint = on.
set printbact = listing.


...
...


set mprint = off.
set printbact = none.

!enddefine.

run the code and then check the log.
You will sometimes get lucky and be able to see what is going wrong when
the log shows the expanded code.
Post by Karovaldas
Thanks for a simplifying suggestion, Bruce; however, I am still stuck
in the LOOP. Even if this one will work magically, I am sure I'll make
mistakes other places and then I have to exit the file and reopen it in
order to continue work.
n***@msn.com
2006-05-27 21:40:48 UTC
Permalink
Simplicity is your friend!!!
You are missing the command terminator on the END LOOP!!!!
I bet that will rectify the problem ;-)))

I might go with:
COMPUTE D(#I) = Stage = 4 AND RTime = #I+2 .
that will set the non candidates to 0 and the candidates to 1.
No need for all those messy parentheses.
Also get rid of the EXE (unnecessary data pass).
HTH, Neila

djhurio
2006-05-24 15:26:54 UTC
Permalink
Just run several times (depends how much unclosed loops you have) END
LOOP. command.
Jonathan Fry
2006-05-24 18:20:26 UTC
Permalink
Post by Karovaldas
I've been writing loops and making mistakes. Unfortunately, after I
make a mistake that results in an unclosed LOOP, I have to close and
re-open the data file because it becomes locked. The status line reads
"Transformations Pending", but running transformations only yield more
error messages telling me that a DO or a LOOP is not closed.
Is there a way to tell the program to ignore the error and discard the
pending transformatoins?
Also, I am not entirely sure what's wrong with the LOOP itself. Below
is a part of it that sometimes works and sometimes does not. I used a
"DO IF ... ELSE IF" sequence and eventualy had to resort to single DO
IF within a loop. Can LOOP handle multiple ELSE IF structure?
VECTOR D=Dble3 TO Dble13 .
LOOP #I = 1 TO 11 .
- DO IF Stage = 4 .
+ DO IF RTime = #I+2 .
+ COMP D(#I) = 1 .
+ END IF .
- END IF .
END LOOP
EXE .
Thanks,
Haris
The command for that is CLEAR TRANSFORMS.

Jonathan Fry
SPSS Inc.
Jonathan Fry
2006-05-24 18:24:24 UTC
Permalink
Post by Karovaldas
I've been writing loops and making mistakes. Unfortunately, after I
make a mistake that results in an unclosed LOOP, I have to close and
re-open the data file because it becomes locked. The status line reads
"Transformations Pending", but running transformations only yield more
error messages telling me that a DO or a LOOP is not closed.
Is there a way to tell the program to ignore the error and discard the
pending transformatoins?
Also, I am not entirely sure what's wrong with the LOOP itself. Below
is a part of it that sometimes works and sometimes does not. I used a
"DO IF ... ELSE IF" sequence and eventualy had to resort to single DO
IF within a loop. Can LOOP handle multiple ELSE IF structure?
VECTOR D=Dble3 TO Dble13 .
LOOP #I = 1 TO 11 .
- DO IF Stage = 4 .
+ DO IF RTime = #I+2 .
+ COMP D(#I) = 1 .
+ END IF .
- END IF .
END LOOP
EXE .
Thanks,
Haris
----------------------------------
I'm not certain what effect you're looking for here. If you want all the
elements of D except the one matching RTime to be zero, and that one to be
one, that would look like

VECTOR D=Dble3 TO Dble13 .
LOOP #I = 1 TO 11 .
- COMPUTE D(#I) = RTime = #I+2.
END LOOP.

Jonathan Fry
SPSS Inc.
Loading...