cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
Uribo
Level II

Loop(FOR) / basic

 
Dear Masters,
 
Nice to meet you.

I tried to double loop with the script , attached csv data but it will not be the result I think.

The minimum value of the difference between the A column and B 1, the minimum value of the difference between the A column and B 2, the minimum value of the difference between the A column and B 3,........difference between column A and B10.

I wanted to output the minimum value of the difference between column A and B until B10, but only the minimum value of difference between A1 and B1, value was "-8", is output.
 
 
 
--------------------------------------------------
db = Current Data Table();
temp = Column( "A" ) << Get Values;
temp2 = Column( "B" )<< Get Values;

Row = N Row( db );
a=0;

For( i = 1,Row, i++,
a=temp[i];

g=0
For( j = 1, Row, j++,
g = temp2[j];
Col Minimum(a-g );
);
);
------------------------------------------------------

Thank you for your kind support.
 
Uribo
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Loop(FOR) / basic

You have 2 issues of syntax.

1. The For() loop requires the termination expression to be a comparison of some sort.  

2. You have specified a column called "A" and a memory variable called "a".  Because you did not show any scoping to indicate that the variable "a" is to be treated as a memory variable, JMP assumed you were referring to the column "A".  Remember, JMP is not case specific.

Here is a corrected version of your script

db = Current Data Table();
temp = Column( "A" ) << Get Values;
temp2 = Column( "B" ) << Get Values;

Row = N Row( db );
::a = 0;

For( i = 1, i <= Row, i++,
	::a = temp[i];

	g = 0;
	For( j = 1, j <= Row, j++,
		g = temp2[j];
		Col Minimum( a - g );
	);
);
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Loop(FOR) / basic

You have 2 issues of syntax.

1. The For() loop requires the termination expression to be a comparison of some sort.  

2. You have specified a column called "A" and a memory variable called "a".  Because you did not show any scoping to indicate that the variable "a" is to be treated as a memory variable, JMP assumed you were referring to the column "A".  Remember, JMP is not case specific.

Here is a corrected version of your script

db = Current Data Table();
temp = Column( "A" ) << Get Values;
temp2 = Column( "B" ) << Get Values;

Row = N Row( db );
::a = 0;

For( i = 1, i <= Row, i++,
	::a = temp[i];

	g = 0;
	For( j = 1, j <= Row, j++,
		g = temp2[j];
		Col Minimum( a - g );
	);
);
Jim
Uribo
Level II

Re: Loop(FOR) / basic

Dear txnelson, 

 

Thank you very much for your quick reply, and polite commentary .

I was saved because the JMP script was at a loss as a novice beginner.

 

Regars,

Uribo