Hi,
The following code is doing exactly what I wanted it to do - loop. loop. do if (begin = 999). compute turns = cnt_turns. compute #turns = turns. else if (begin NE 999). compute turns = #turns. compute #i = begin. end if. end case. end loop if #i=1. end loop if (tape_num = $sysmis). exe. BUT gives this error message: >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: 157 Current case: 508 Current splitfile group: 1 WHY IS THAT? TAHNKS, Uri |
Administrator
|
That code may "doing exactly what I wanted it to do".
Probably much more efficient ways to do "it". If only we knew what "it" was that "you wanted to do?" -------- From the FM: "Reference > Command Syntax Reference > SET MXLOOPS Subcommand (SET command) MXLOOPS specifies the maximum number of times that a loop that is defined by the LOOP-END LOOP structure is executed for a single case or input record. The default is 40. MXLOOPS prevents infinite loops, which may occur if no cutoff is specified for the loop structure (see LOOP-END LOOP). MXLOOPS will limit the number of loops for any loop structure that doesn't have an indexing clause, including loops with conditional IF clauses. If a loop has an indexing clause (e.g., LOOP #i=1 to 1000), the indexing clause overrides the MXLOOPS setting. When a loop is terminated, control passes to the command immediately following the END LOOP command, even if the END LOOP condition is not yet met."
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
At 09:00 AM 12/29/2014, David Marso wrote, quoted uri1616, who had written,
>The following code [somewhat reformatted] is doing exactly what I >wanted it to do, BUT gives this error message: >>Warning # 534 >>Execution of a loop was terminated after MXLOOPS trips. > >loop. > loop. > do if (begin = 999). > compute turns = cnt_turns. > compute #turns = turns. > else if (begin NE 999). > compute turns = #turns. > compute #i = begin. > end if. > end case. > end loop if #i=1. >end loop if (tape_num = $sysmis). Like David, I've no idea what you're trying to do, because you've left out crucial information. However, you have two loops, and at least part of your problem is the closing statement of the outer one: end loop if (tape_num = $sysmis). That 'if' condition can *NEVER* be satisfied. Nothing can be "equal to" $sysmis, because $sysmis isn't a value, in SPSS's sense; a test of anything being "equal to" $sysmis returns 'missing'. So your outer loop ran for MXLOOPS passes, and then gave you the warning that you saw. The correct version of that statement is end loop if (SYSMIS(tape_num)). ===================== 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 |
In reply to this post by uri1616
At 09:00 AM 12/29/2014, David Marso wrote, quoted uri1616, who had written,
>The following code [somewhat reformatted, below] is doing exactly >what I wanted it to do I'm glad you're getting what you want; but the logic looks a little strange, even correcting the syntax error I previously noted. . The (corrected) exit condition for the outer loop is >end loop if (tape_num = $sysmis) /* Corrected */. The value of "tape_num" doesn't seem to be modified in your code; so, even corrected, your outer loop will pass exactly once, or MXLOOPS times, depending on whether "tape_num" is system-missing or not. . The exit condition for the inner loop is > end loop if #i=1. It appears that this condition is satisfied if and only if the value of "begin" is 1 at entry to this code block. So, the inner loop, also, should be passed either once or MXLOOPS times. >loop. > loop. > do if (begin = 999). > compute turns = cnt_turns. > compute #turns = turns. > else if (begin NE 999). > compute turns = #turns. > compute #i = begin. > end if. > end case. > end loop if #i=1. >end loop if (SYSMIS(tape_num)) /* Corrected */. ===================== 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 |
Please explain in more detail what you are trying to do.
As Rich pointed out you tested whether something was equal to sysmis. It is better practice in the long run to reserve SYSMIS for its purpose -- to indicate when the computer is not able to follow your instructions. Any occurrence of sysmis should be a flag that you need to redraft your syntax. User-missing values indicate that you know why the value is missing. Are you trying to see if a variable has not been initialized, a better way is to explicitly initialize it before the section where it will be used. Initialize it with a user-missing value.
Art Kendall
Social Research Consultants |
Free forum by Nabble | Edit this page |