cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • 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.
  • JMP will suspend normal business operations for our Rest and Recharge Day on Friday, October 2, 2026.
    Regular business hours will resume on Monday, October 5, 2026.

Discussions

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

Max value of each row across multiple columns JMP10

When I run below script in JMP 10, I get an error message that says - argument should be matrix{1} in access or evaluation of 'Loc Max' , Bad Argument ...

Looks like data table indexing is a feature in JMP13. What would be the work around in JMP10?

dt = New Table( "Untitled",
New Column( "a", Numeric, Set Values( [1, 33, 1] ) ),
New Column( "b", Numeric, Set Values( [2, 2, 2] ) ),
New Column( "c", Numeric, Set Values( [333, 1, 0] ) ),
New Column( "maxval", numeric ),
New Column( "maxcol", Numeric )
);

colnames = dt << getcolumnnames;

For Each Row(
r = Row();
// 1::3 means columns 1 through 3. {a,b,c} would also work.
location = Loc Max( dt[ r, 1 :: 3] ); // location of maximum value in array
maxval = dt[r, location];
maxcol = colnames[location] << getname;
);

 

Thanks!

1 REPLY 1

Re: Max value of each row across multiple columns JMP10

You can get the values as a matrix first and then grab each row from the matrix instead of the data table:

dt = New Table( "Untitled",
	New Column( "a", Numeric, Set Values( [1, 33, 1] ) ),
	New Column( "b", Numeric, Set Values( [2, 2, 2] ) ),
	New Column( "c", Numeric, Set Values( [333, 1, 0] ) ),
	New Column( "maxval", numeric ),
	New Column( "maxcol", Numeric )
);

colnames = dt << getcolumnnames;

values = dt << Get As Matrix;

For Each Row(
	r = Row();
	// 1::3 means columns 1 through 3. {a,b,c} would also work.
	location = Loc Max( values[r, 1 :: 3] ); // location of maximum value in array
	maxval = dt[r, location];
	maxcol = colnames[location] << getname;
);

Recommended Articles