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
djmomo
Level I

Selecting data for past X number of days

I have a data set that contains past 60 days of data and I want just past 7 days of data. Data column name "OUT_DATE" in the format of   MM/DD/YYY HH:MM:SS AM/PM. Date is not sorted and in random order.

 

I found the following discussion answered by super user "txnelson" (https://community.jmp.com/t5/Discussions/Date-function-in-jsl/td-p/57122) and did my script as below

 

dt=Open("Report.csv");// Opening the main datafile
P7D = dt << select where( today() - In Days( 7 ) < :OUT_DATE );// Selecting past 7 days data and assigning it to P7D
P7D << Save("P7D.csv");// Save P7D as csv

But my output file "P7D.csv" has an exact copy of the "Report.csv".

 

 

How can I store only past 7 days of data in P7D?

3 REPLIES 3
txnelson
Super User

Re: Selecting data for past X number of days

Selection of given rows does not affect the saving.  The easiest way to do that, is to create a subset of the data, based upon the selection, and then save that subset. (The below is corrected code: see @gzmorgan0 )

names default to here(1);
dt=Open("Report.csv");// Opening the main datafile
dt << select where( today() - In Days( 7 ) < :OUT_DATE );// Selecting past 7 days data and assigning it to P7D
P7D = dt << subset(invisible, selected columns(0), selected rows(1));
P7D << Save("P7D.csv");// Save P7D as csv
close( P7D, nosave);

 

Jim
gzmorgan0
Super User (Alumni)

Re: Selecting data for past X number of days

Just a simple correction, @txnelson nice solution is missing an equal sign. Line 4 should be

P7D = dt << subset(invisible, selected columns(0), selected rows(1));

 

txnelson
Super User

Re: Selecting data for past X number of days

Thanks for the catch

Jim

Recommended Articles