<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Identifying and labeling events in a time series in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Identifying-and-labeling-events-in-a-time-series/m-p/254250#M49912</link>
    <description>&lt;P&gt;Please find one approach (no doubt of many). Using the summary table allows linking to the source table, which might be useful. Do 'File &amp;gt; New &amp;gt; New Script', cut and paste the code below, then 'Edit &amp;gt; Run Script'.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NamesDefaultToHere(1);

// Make some fake data to play with
n = 1000;
startDate = Date DMY( 01, 1, 2016 );
endDate = Date DMY( 12, 10, 2016 );
dates = Sort Ascending(J( n, 1, Random Integer(startDate, endDate) ) );
status = J( n, 1, Random Integer(1, 2) );
dt1 = New Table( "Callibrations",
			New Column( "Date", Numeric, "Continuous", Format( "ddMonyyyy h:m", 35 ), Set Values( dates )),
			New Column( "Status", Numeric, "Nominal", Set Values( status ), Value Labels( {1 = "NORMAL", 2 = "CALIB"} ) )
			);

/************************************************************************************************/
/* Start here . . .                                                                             */
/************************************************************************************************/
dt1 = CurrentDataTable();

// Define a column that increments when the 'Status' changes:
// https://community.jmp.com/t5/Discussions/Formula-for-automatic-counter-by-group-of-rows/td-p/20120
dt1 &amp;lt;&amp;lt; New Column( "Counter", Numeric, "Ordinal", Formula( If( Row() == 1, 1, Lag( :Counter, 1 ) + (Lag( :Status, 1 ) != :Status)) ) );

// Get the start dates 
dt1 &amp;lt;&amp;lt; New Column( "Start Date", Numeric, "Continuous", Format( "ddMonyyyy h:m", 35 ), Formula( Col Min( :Date, :Counter ) ));

// Get the end dates 
dt1 &amp;lt;&amp;lt; New Column( "End Date", Numeric, "Continuous", Format( "ddMonyyyy h:m", 35 ), Formula( Col Max( :Date, :Counter ) ));

// Make the required summary table
dt2 = dt1 &amp;lt;&amp;lt; Summary(
					Group( :Counter, :Status ),
					Min( :Start Date ),
					Max( :End Date ),
					statistics column name format( "column" ),
					output table name( "Calibration Periods" )
					);
dt2 &amp;lt;&amp;lt; deleteProperty("Source");&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 25 Mar 2020 15:51:48 GMT</pubDate>
    <dc:creator>ian_jmp</dc:creator>
    <dc:date>2020-03-25T15:51:48Z</dc:date>
    <item>
      <title>Identifying and labeling events in a time series</title>
      <link>https://community.jmp.com/t5/Discussions/Identifying-and-labeling-events-in-a-time-series/m-p/254032#M49877</link>
      <description>&lt;P&gt;I have a large time series(~250,000) of minute data analyzer status values (character values). The values are NORMAL for when the analyzer is operating normally and CALIB during calibration. The calibrations occur daily but at various times (not the same time every day) and last for various durations usually around 30 minutes. Each one minute data point is timestamped. I need to assign each calibration period (from the beginning of cal status CALIB to the end of cal status CALIB for a given day) a unique identifier and generate a table with the start and end times for each calibration period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm a complete novice at JSL. Can anyone provide an example of how I might accomplish this with JSL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any help.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 20:07:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Identifying-and-labeling-events-in-a-time-series/m-p/254032#M49877</guid>
      <dc:creator>scott1588</dc:creator>
      <dc:date>2020-03-24T20:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying and labeling events in a time series</title>
      <link>https://community.jmp.com/t5/Discussions/Identifying-and-labeling-events-in-a-time-series/m-p/254250#M49912</link>
      <description>&lt;P&gt;Please find one approach (no doubt of many). Using the summary table allows linking to the source table, which might be useful. Do 'File &amp;gt; New &amp;gt; New Script', cut and paste the code below, then 'Edit &amp;gt; Run Script'.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NamesDefaultToHere(1);

// Make some fake data to play with
n = 1000;
startDate = Date DMY( 01, 1, 2016 );
endDate = Date DMY( 12, 10, 2016 );
dates = Sort Ascending(J( n, 1, Random Integer(startDate, endDate) ) );
status = J( n, 1, Random Integer(1, 2) );
dt1 = New Table( "Callibrations",
			New Column( "Date", Numeric, "Continuous", Format( "ddMonyyyy h:m", 35 ), Set Values( dates )),
			New Column( "Status", Numeric, "Nominal", Set Values( status ), Value Labels( {1 = "NORMAL", 2 = "CALIB"} ) )
			);

/************************************************************************************************/
/* Start here . . .                                                                             */
/************************************************************************************************/
dt1 = CurrentDataTable();

// Define a column that increments when the 'Status' changes:
// https://community.jmp.com/t5/Discussions/Formula-for-automatic-counter-by-group-of-rows/td-p/20120
dt1 &amp;lt;&amp;lt; New Column( "Counter", Numeric, "Ordinal", Formula( If( Row() == 1, 1, Lag( :Counter, 1 ) + (Lag( :Status, 1 ) != :Status)) ) );

// Get the start dates 
dt1 &amp;lt;&amp;lt; New Column( "Start Date", Numeric, "Continuous", Format( "ddMonyyyy h:m", 35 ), Formula( Col Min( :Date, :Counter ) ));

// Get the end dates 
dt1 &amp;lt;&amp;lt; New Column( "End Date", Numeric, "Continuous", Format( "ddMonyyyy h:m", 35 ), Formula( Col Max( :Date, :Counter ) ));

// Make the required summary table
dt2 = dt1 &amp;lt;&amp;lt; Summary(
					Group( :Counter, :Status ),
					Min( :Start Date ),
					Max( :End Date ),
					statistics column name format( "column" ),
					output table name( "Calibration Periods" )
					);
dt2 &amp;lt;&amp;lt; deleteProperty("Source");&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Mar 2020 15:51:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Identifying-and-labeling-events-in-a-time-series/m-p/254250#M49912</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2020-03-25T15:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying and labeling events in a time series</title>
      <link>https://community.jmp.com/t5/Discussions/Identifying-and-labeling-events-in-a-time-series/m-p/254274#M49921</link>
      <description>This is perfect.Thanks, Ian. The support JMP and the dedicated users provides for the JMP community is awesome. It provides incredible value.</description>
      <pubDate>Wed, 25 Mar 2020 19:15:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Identifying-and-labeling-events-in-a-time-series/m-p/254274#M49921</guid>
      <dc:creator>scott1588</dc:creator>
      <dc:date>2020-03-25T19:15:58Z</dc:date>
    </item>
  </channel>
</rss>

