cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

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