cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Instantly extract effect sizes, F-ratios, and FDR-adjusted p-values from your models with the Calculate Effects Sizes extension, available now in the JMP Marketplace!
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

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