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.
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

Discussions

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

How to set values for last 30 rows of a column?

Hi guys, 

I'm a complete scripting newbie here so please have patience with me :crossed_fingers:.  I have a data set with multiple columns and am trying to make a script that will automatically select the last 30 rows of a column and change the content from "baseline" to "CLCR". Please see my attempt:

 

dt = Current Data Table();
dt1 = dt << Select Columns( :CLCR );
dt1 << select where( Row() > N Rows( dt ) - 30 );
dt1 << set value ("CLCR");

Should I have taken the for loop or while loop approach? 

 

THANKS GUYS ✌

Kristijan Krog
1 REPLY 1
jthi
Super User

Re: How to set values for last 30 rows of a column?

I would use datatable subscripting:

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

dt[N Rows(dt) - 29::N Rows(dt), "height"] = 0;

Edit, one more option:

You can also use get rows where to get specific rows. You can use similar where argument here as you would in select where

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

// get rows into a matrix
r = dt << Get Rows Where(Row() > N Rows(dt) - 30);

// set values
Column(dt, "height")[r] = 0;

 

-Jarmo

Recommended Articles