Hi All,
I have a data table that consists of dated entries where the most recent entry is at the top of the table and the oldest entry is at the bottom.
What I'm trying to do is loop through the rows to find the date difference between two rows. I've done this with the following code, got it from a post that @txnelson answered some time ago (sorry don't have the OP in front of me).
dt = Data Table( "My Data" );
For( i=N Rows(dt), i >= 2, i--,
:ct[i] = Abs(DateDifference(:date[i-1], :date[i], "Day"));
);
This works great, and I can find all date differences of interest.
However, what I really want to do is to label date ranges with alphabet letters (A, B, C, D, etc.).
For example, if my first entry (last row in data table) starts on 01/01/2017 (dd/mm/yyyy), I want to label that row "A", and want to continue labeling the rows going up the column until it reaches a point where the difference in dates is >=n (in this case n=2, but could be any number bigger than 1).
Keep in mind that the dates are increasing as we work up from the bottom of the table. So, the next row above would be 02/01/2017. Let's say this goes on until the end of January, so there are 31 rows going from 01/01/2017 to 31/01/2017.
At the next row above 31/01/2017, we have 05/02/2017. So the date difference is 5. I would like to then have my label tracker start labeling it as "B" until the next date change where the difference is >=2 and then start labeling as "C", and so on until the data table has finished.
Something close to this was also posted by @txnelson in this thread: https://community.jmp.com/t5/Discussions/Labeling-rows-as-greater-less-than-a-date-with-JSL/td-p/36376, but it requires a specified start date to compare other dates to. I don't want to have a specified start date, but rather have it done automatically based on whatever dates have populated the table.
Any suggestions/support is greatly appreciated.
Thanks!