cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
LBrian
Level III

How to change Col Value in selected row?

Hi, everyone.

I want to change Col value in only selected row using JSL.

(ex, second Col value : 14 -> 9999)

 

Can I get some advice?

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Current Data Table() << Sort( replace table, Column( address, 2 ), Order( Ascending ) );
Current Data Table() << Sort( replace table, Column( address, 4 ), Order( Ascending ) );
//wait(1);
dt << Select duplicate rows( Match( Column(dt, 2), Column(dt, 3 ), Column(dt, 4 ) ) );

 

I can't complete it...

Please help me.

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to change Col Value in selected row?

I have annotated my JSL as to what is the correct JSL to do what you are looking to do

names default to here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

// The sort is not required for the Select duplicate rows to work
// The 2 sorts you specified, first sorted all of the rows by age and
// then sorted all of the rows by height.  I think what you were looking
// to do, was to sort all of the heights within each age group.  That
// would be accomplished with the line of code below 
dt << Sort( replace table, by( Column(  2 ),Column(  4 ) ), Order( Ascending, Ascending ) );

dt << Select duplicate rows( Match( Column( dt, 2 ), Column( dt, 3 ), Column( dt, 4 ) ) );

aa = dt <<get selected rows;

If( N Rows( aa ) > 0,
	// All you need is a simple assignment statement setting all of the rows found for the column
	// age equal to 9999
	(Column(dt,2)[aa]) = 9999;
);
Jim

View solution in original post

3 REPLIES 3
LBrian
Level III

Re: How to change Col Value in selected row?

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Current Data Table() << Sort( replace table, Column( address, 2 ), Order( Ascending ) );
Current Data Table() << Sort( replace table, Column( address, 4 ), Order( Ascending ) );
//wait(1);
dt << Select duplicate rows( Match( Column( dt, 2 ), Column( dt, 3 ), Column( dt, 4 ) ) );

aa = dt <<get selected rows;

If( N Rows( aa ) > 0,
	Column(dt,2) << Set Values("9999");
);
	

I don't know why it doesn't work.

txnelson
Super User

Re: How to change Col Value in selected row?

I have annotated my JSL as to what is the correct JSL to do what you are looking to do

names default to here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

// The sort is not required for the Select duplicate rows to work
// The 2 sorts you specified, first sorted all of the rows by age and
// then sorted all of the rows by height.  I think what you were looking
// to do, was to sort all of the heights within each age group.  That
// would be accomplished with the line of code below 
dt << Sort( replace table, by( Column(  2 ),Column(  4 ) ), Order( Ascending, Ascending ) );

dt << Select duplicate rows( Match( Column( dt, 2 ), Column( dt, 3 ), Column( dt, 4 ) ) );

aa = dt <<get selected rows;

If( N Rows( aa ) > 0,
	// All you need is a simple assignment statement setting all of the rows found for the column
	// age equal to 9999
	(Column(dt,2)[aa]) = 9999;
);
Jim
LBrian
Level III

Re: How to change Col Value in selected row?

Thank you, very much!!!