cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Instantly extract effect sizes, F-ratios, and FDR-adjusted p-values from your models with the Calculate Effects Sizes extension, available now in the JMP Marketplace!
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • See how to use the JMP Marketplace – Free tools to expand JMP capabilities. Register. July 10, 2 pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
lwx228
Level VIII

How do I exit the loop when something is satisfied?

After the data table is sorted by the age column in ascending order, the cycle is conducted by the age column. When the age is equal to the age of the previous row, n=n+1, otherwise, the cycle is withdrawn.Thank you!

 

 

dt = Open( "$SAMPLE_DATA\Big class.jmp" );
r = N Row( dt );
n = 0;
For( i == 2, i <= r, i++,
If( dt[i - 1, "age"] = dt[i, "age"],
n = n + 1,
stop loop
);

);

 

 

2018-10-06_20-34-57.png

1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: How do I exit the loop when something is satisfied?

You want the BREAK command.  From the scripting index:

Names Default To Here( 1 );
For( i = 1, i <= 10, i++,
	If( i == 5, Break() );
	Print( "i=" || Char( i ) );
);

View solution in original post

1 REPLY 1
pmroz
Super User

Re: How do I exit the loop when something is satisfied?

You want the BREAK command.  From the scripting index:

Names Default To Here( 1 );
For( i = 1, i <= 10, i++,
	If( i == 5, Break() );
	Print( "i=" || Char( i ) );
);

Recommended Articles