cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP Security Notice: CVE-2026-109618 and CVE-2026-109619

    JMP promptly initiated a review of its products, services, and relevant infrastructure for exposure to CVE-2026-109618 and CVE-2026-109619.

    Our assessment of JMP products has not identified exposure to these vulnerabilities. Where remediation was required within supporting environments, appropriate security updates and controls have been applied and validated.

    We have identified no evidence of successful exploitation or unauthorized access to JMP systems or customer information associated with these vulnerabilities.

    JMP continues to monitor the issue and relevant vendor guidance. No action is required by JMP customers at this time.

  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.

Discussions

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

How do I perform row operations in looping?

Hello,

I have a table like below.

A B C ..n columns

1 2 3

7 6 4

3 7 9

.

.

m rows

I want to write a script such that for every column " Value of nth row= Value of nth row -Value of 1st row" and in the end reset the first row to 0. So in the end my table should look like

A B C

0 0 0..

6 4 1

2 5 6

.

.

Could someone help me with a script for such an operation? Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How do I perform row operations in looping?

Here are a couple of ways to do the looping........more ways exist, but I will let others show them

Names Default To Here( 1 );

// Open the data table
dt1 = Open( "$SAMPLE_DATA\Blood Pressure.jmp" );

// Create a second copy
dt2 = dt1 << subset( selected columns( 0 ), selected rows( 0 ) );

// Get all numeric, continuous column names 
colList = dt1 << get column names( string, numeric, continuous );

// Loop across all numeric, continuous columns and use a 
// matrix operation to handle the math
For( i = 1, i <= N Items( colList ), i++,
	mat = Column( dt1, colList[i] ) << get values;
	mat = mat - mat[1];
	Column( dt1, colList[i] ) << set values( mat );
);


// Now do the same thing looping with the data in place
// Loop across all numeric, continuous columns
For( i = 1, i <= N Items( colList ), i++, 

	// Go through each row, from the bottom to the top to subtract
	// the value of the first row from each rows value
	For( k = N Rows( dt2 ), k >= 1, k--,
		Column( dt2, colList[i] )[k] = Column( dt2, colList[i] )[k] - Column( dt2, colList[i] )[1]
	)
);
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: How do I perform row operations in looping?

Here are a couple of ways to do the looping........more ways exist, but I will let others show them

Names Default To Here( 1 );

// Open the data table
dt1 = Open( "$SAMPLE_DATA\Blood Pressure.jmp" );

// Create a second copy
dt2 = dt1 << subset( selected columns( 0 ), selected rows( 0 ) );

// Get all numeric, continuous column names 
colList = dt1 << get column names( string, numeric, continuous );

// Loop across all numeric, continuous columns and use a 
// matrix operation to handle the math
For( i = 1, i <= N Items( colList ), i++,
	mat = Column( dt1, colList[i] ) << get values;
	mat = mat - mat[1];
	Column( dt1, colList[i] ) << set values( mat );
);


// Now do the same thing looping with the data in place
// Loop across all numeric, continuous columns
For( i = 1, i <= N Items( colList ), i++, 

	// Go through each row, from the bottom to the top to subtract
	// the value of the first row from each rows value
	For( k = N Rows( dt2 ), k >= 1, k--,
		Column( dt2, colList[i] )[k] = Column( dt2, colList[i] )[k] - Column( dt2, colList[i] )[1]
	)
);
Jim
PG
PG
Level I

Re: How do I perform row operations in looping?

Thanks txnelson. It works perfectly.

Recommended Articles