MXLOOPS query

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

MXLOOPS query

Mark Webb-5
Hi all
Gene Maguin shared syntax with me awhile ago to sort variables within
record .
When I run it it works exactly as expected but gives a error warning
about MXLOOPS.
I would like to understand why - and I suspect it comes from the Loop.
command which confuses me as I'm used to the form Loop #i=1 to 3 for
example not just Loop.
Any comments ?
#######################################################################
The error message - appears twice as shown below.

 >Warning # 534
 >Execution of a loop was terminated after MXLOOPS trips.  The value of
MXLOOPS
 >can be displayed with the SHOW command and changed with the SET command.
 >Command line: 339  Current case: 1  Current splitfile group: 1


 >Warning # 534
 >Execution of a loop was terminated after MXLOOPS trips.  The value of
MXLOOPS
 >can be displayed with the SHOW command and changed with the SET command.
 >Command line: 339  Current case: 2  Current splitfile group: 1


##############################################################################
The Syntax

****From Gene Maguin   [hidden email] <[hidden email]>.
**** Missing vars = 999.   Missing vars turned off in SPSS. List less
than 999 .
*NB-Replaces data so loose original data - make copy of vars if original
data still required.
***********************************************************************.
**This makes a copy of the original variables.
************************************************************************.
Vector oldc(5).
Compute #cnt=1.
Do repeat
x = c1 to c5.
Compute oldc(#cnt) = x.
Compute #cnt = #cnt+1.
End repeat.
Exe.
*************************************.
***This does the sorting.
*************************************.
Vector c=oldc1 to oldc5.
compute swap=0.
Loop.
+   Loop #i=1 to 4. /*Always 1 less than the vector.
+       Do if (c(#i) gt c(#i+1)).
+       compute temp=c(#i).
+       compute c(#i)=c(#i+1).
+       compute c(#i+1)=temp.
+       compute swap=1.
+       End if.
+   End loop.
End loop if (swap eq 0).
exe.

--
Mark Webb

Line +27 (21) 786 4379
Cell +27 (72) 199 1000
Fax to email +27 (86) 5513075
Skype  webbmark
Email  [hidden email]

=====================
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: MXLOOPS query

Maguin, Eugene
Hi Mark,

I think the problem is that once you do the first interchange and swap then
equals 1, there is no way that swap will every be 0 again. So, it loops and
loops. Change the code as shown and I think it will work because every time
you go through the outer loop, swap is reset to 0.

Vector c=oldc1 to oldc5.
compute swap=0.  <<<< Move from here
Loop.
compute swap=0.  <<<< to here
+   Loop #i=1 to 4. /*Always 1 less than the vector.
+       Do if (c(#i) gt c(#i+1)).
+       compute temp=c(#i).
+       compute c(#i)=c(#i+1).
+       compute c(#i+1)=temp.
+       compute swap=1.
+       End if.
+   End loop.
End loop if (swap eq 0).
exe.


Gene Maguin




-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Mark Webb
Sent: Wednesday, April 20, 2011 3:12 AM
To: [hidden email]
Subject: MXLOOPS query

Hi all
Gene Maguin shared syntax with me awhile ago to sort variables within
record .
When I run it it works exactly as expected but gives a error warning
about MXLOOPS.
I would like to understand why - and I suspect it comes from the Loop.
command which confuses me as I'm used to the form Loop #i=1 to 3 for
example not just Loop.
Any comments ?
#######################################################################
The error message - appears twice as shown below.

 >Warning # 534
 >Execution of a loop was terminated after MXLOOPS trips.  The value of
MXLOOPS
 >can be displayed with the SHOW command and changed with the SET command.
 >Command line: 339  Current case: 1  Current splitfile group: 1


 >Warning # 534
 >Execution of a loop was terminated after MXLOOPS trips.  The value of
MXLOOPS
 >can be displayed with the SHOW command and changed with the SET command.
 >Command line: 339  Current case: 2  Current splitfile group: 1


############################################################################
##
The Syntax

****From Gene Maguin   [hidden email] <[hidden email]>.
**** Missing vars = 999.   Missing vars turned off in SPSS. List less
than 999 .
*NB-Replaces data so loose original data - make copy of vars if original
data still required.
***********************************************************************.
**This makes a copy of the original variables.
************************************************************************.
Vector oldc(5).
Compute #cnt=1.
Do repeat
x = c1 to c5.
Compute oldc(#cnt) = x.
Compute #cnt = #cnt+1.
End repeat.
Exe.
*************************************.
***This does the sorting.
*************************************.
Vector c=oldc1 to oldc5.
compute swap=0.
Loop.
+   Loop #i=1 to 4. /*Always 1 less than the vector.
+       Do if (c(#i) gt c(#i+1)).
+       compute temp=c(#i).
+       compute c(#i)=c(#i+1).
+       compute c(#i+1)=temp.
+       compute swap=1.
+       End if.
+   End loop.
End loop if (swap eq 0).
exe.

--
Mark Webb

Line +27 (21) 786 4379
Cell +27 (72) 199 1000
Fax to email +27 (86) 5513075
Skype  webbmark
Email  [hidden email]

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

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