cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
chadyoder
Level I

Scripting a table subset based upon the last 3 months of data

Hello,

 

I have a large data set that spans about 3 years and it is getting added to constantly.  Every quarter I want to run some script but I need to pull a subset of  just the last 3 months or so.  I know that I can set a Data Filter and  set the minimum date and then run a subset on that selection.

 

However, I want to be able to send some script to other members of my team who do similar work with different accounts.  What I would like to do is have  script where i can just simply type in the minimum date that I want and it will create a data subset with just those observations.  Then I can run script on those specific observations only.

 

Does anyone have script that will do that?

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Scripting a table subset

Hi chadyoder,

The following script asks for the last entry in the data table of the date column and creates a data filter for all 10 days before the last entered date. You can adjust it to any kind of date Format of course, but should help you for the next step. The data table looks like the following:

     7753_pastedImage_4.png

===== 

dt = Current Data Table();

dt << Data Filter(

     Location( {198, 198} ),

     Mode( Show( 1 ), Include( 1 ) ),

     Add Filter(

          columns( :Date ),

          Where( :Date >= (:Date[N Rows (Current Data Table())]-(60*60*24*10)) ),

          Display( :Date )

     ) 

);

Distribution(

     Arrange in Rows( 4 ),

     Continuous Distribution( Column( :Sunspots ), Count Axis( 1 ) ),

     SendToReport(

          Dispatch(

              {"Distributions", "Measurement"},

                                     "Distrib Histogram",

              FrameBox,

              {DispatchSeg( Hist Seg( 1 ), Histogram Color( 42 ) )}

          )

     )

);

=====

The (60*60*24*10) stands for 60 seconds times 60 minutes times 24 hours times 10 days, so including the last row date you select 11 last rows of Date column.

The result looks like:

7754_pastedImage_0.png

Hope that helps, Martin

/****NeverStopLearning****/

View solution in original post

1 REPLY 1

Re: Scripting a table subset

Hi chadyoder,

The following script asks for the last entry in the data table of the date column and creates a data filter for all 10 days before the last entered date. You can adjust it to any kind of date Format of course, but should help you for the next step. The data table looks like the following:

     7753_pastedImage_4.png

===== 

dt = Current Data Table();

dt << Data Filter(

     Location( {198, 198} ),

     Mode( Show( 1 ), Include( 1 ) ),

     Add Filter(

          columns( :Date ),

          Where( :Date >= (:Date[N Rows (Current Data Table())]-(60*60*24*10)) ),

          Display( :Date )

     ) 

);

Distribution(

     Arrange in Rows( 4 ),

     Continuous Distribution( Column( :Sunspots ), Count Axis( 1 ) ),

     SendToReport(

          Dispatch(

              {"Distributions", "Measurement"},

                                     "Distrib Histogram",

              FrameBox,

              {DispatchSeg( Hist Seg( 1 ), Histogram Color( 42 ) )}

          )

     )

);

=====

The (60*60*24*10) stands for 60 seconds times 60 minutes times 24 hours times 10 days, so including the last row date you select 11 last rows of Date column.

The result looks like:

7754_pastedImage_0.png

Hope that helps, Martin

/****NeverStopLearning****/