<?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 Subset a list using various conditions in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Subset-a-list-using-various-conditions/m-p/31113#M19693</link>
    <description>&lt;P&gt;I have a list of daily moving averages computed from 5-minute data. &amp;nbsp;Although I'm able to successfully create this list, I can't seem to figure out how to locate in thelist when certain conditions are met and to then create a new data table containing the :Date when these conditions are met. &amp;nbsp;The following code grabs the dates corresponding to each record in the ma_list, not just those corresponding the the specified condition. Is it possible to create "complex" evaluation criteria when working with lists, and if so, what might that JSL code look like? &amp;nbsp;Any suggestions would be greatly appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ma_list = [46.6, 51.6, 50.8, 52.8, 58.4, 57.6, 62.2, 62.2, 66.6, 63.8, 59.6, 55.6, 57.2, 57.8,
57.4, 59.8, 65.4, 62, 54.6, 51.8, 50, 45.2, 44.2, 42.2, 45.8, 47.8, 52.4, 55.6, 57,
44.4, 34, 20.2, 9.4, 0.4, 0, 0, 0, 0, 0, 4.4, 11, 18, 25.4, 32.4, 36.6, 38.2, 40.2,
44.6, 44, 41.4, 39, 38.4, 33, 33.8, 39.2, 40.4, 37.8, 37.6, 36.4, 31, 30,
30.3333333333333]

// Locate dates when data shifted from 0 to a positive value&lt;BR /&gt;// NOTE: :Date refers to existing column name in data table ma_list was extracted from.&lt;BR /&gt;ma_date_list = {};&lt;BR /&gt;&lt;BR /&gt;For( i = 2, i &amp;lt;= N Items( ma_list ), i++,&lt;BR /&gt; If ( ma_list[i] &amp;gt; 0 &amp;amp; ma_list[i-1] == 0,&lt;BR /&gt; // then&lt;BR /&gt; ma_date_list = :Date[ma_row_list]&lt;BR /&gt; )&lt;BR /&gt;);&lt;BR /&gt;
&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Dec 2016 20:11:00 GMT</pubDate>
    <dc:creator>terapin</dc:creator>
    <dc:date>2016-12-02T20:11:00Z</dc:date>
    <item>
      <title>Subset a list using various conditions</title>
      <link>https://community.jmp.com/t5/Discussions/Subset-a-list-using-various-conditions/m-p/31113#M19693</link>
      <description>&lt;P&gt;I have a list of daily moving averages computed from 5-minute data. &amp;nbsp;Although I'm able to successfully create this list, I can't seem to figure out how to locate in thelist when certain conditions are met and to then create a new data table containing the :Date when these conditions are met. &amp;nbsp;The following code grabs the dates corresponding to each record in the ma_list, not just those corresponding the the specified condition. Is it possible to create "complex" evaluation criteria when working with lists, and if so, what might that JSL code look like? &amp;nbsp;Any suggestions would be greatly appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ma_list = [46.6, 51.6, 50.8, 52.8, 58.4, 57.6, 62.2, 62.2, 66.6, 63.8, 59.6, 55.6, 57.2, 57.8,
57.4, 59.8, 65.4, 62, 54.6, 51.8, 50, 45.2, 44.2, 42.2, 45.8, 47.8, 52.4, 55.6, 57,
44.4, 34, 20.2, 9.4, 0.4, 0, 0, 0, 0, 0, 4.4, 11, 18, 25.4, 32.4, 36.6, 38.2, 40.2,
44.6, 44, 41.4, 39, 38.4, 33, 33.8, 39.2, 40.4, 37.8, 37.6, 36.4, 31, 30,
30.3333333333333]

// Locate dates when data shifted from 0 to a positive value&lt;BR /&gt;// NOTE: :Date refers to existing column name in data table ma_list was extracted from.&lt;BR /&gt;ma_date_list = {};&lt;BR /&gt;&lt;BR /&gt;For( i = 2, i &amp;lt;= N Items( ma_list ), i++,&lt;BR /&gt; If ( ma_list[i] &amp;gt; 0 &amp;amp; ma_list[i-1] == 0,&lt;BR /&gt; // then&lt;BR /&gt; ma_date_list = :Date[ma_row_list]&lt;BR /&gt; )&lt;BR /&gt;);&lt;BR /&gt;
&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2016 20:11:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Subset-a-list-using-various-conditions/m-p/31113#M19693</guid>
      <dc:creator>terapin</dc:creator>
      <dc:date>2016-12-02T20:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: Subset a list using various conditions</title>
      <link>https://community.jmp.com/t5/Discussions/Subset-a-list-using-various-conditions/m-p/31115#M19695</link>
      <description>&lt;P&gt;See if this approach helps:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;ma_list = [46.6, 51.6, 50.8, 52.8, 58.4, 57.6, 62.2, 62.2, 66.6, 63.8, 59.6, 55.6, 57.2, 57.8,
57.4, 59.8, 65.4, 62, 54.6, 51.8, 50, 45.2, 44.2, 42.2, 45.8, 47.8, 52.4, 55.6, 57,
44.4, 34, 20.2, 9.4, 0.4, 0, 0, 0, 0, 0, 4.4, 11, 18, 25.4, 32.4, 36.6, 38.2, 40.2,
44.6, 44, 41.4, 39, 38.4, 33, 33.8, 39.2, 40.4, 37.8, 37.6, 36.4, 31, 30,
30.3333333333333];

// create parallel vector lagged by 1
lagged data = ma_list[2::NRow(ma_list)];

// remove the last observation
data = ma_list[1::NRow(ma_list)-1];

// find the positive differences
positives = Loc( (lagged data - data) &amp;gt; 0 &amp;amp; (data == 0) );

// go get 'em
ma_date_list = :Date[positives];&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Dec 2016 20:48:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Subset-a-list-using-various-conditions/m-p/31115#M19695</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2016-12-02T20:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: Subset a list using various conditions</title>
      <link>https://community.jmp.com/t5/Discussions/Subset-a-list-using-various-conditions/m-p/33208#M19802</link>
      <description>&lt;P&gt;Thanks Mark for the suggestion,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was hoping we could do some complex forward and backward evaluations of the matrix, but I now see that's not quite possible. &amp;nbsp;Your suggestion certainly helps get the evaluation I needed while also showing me how to go about this type of thing in the future. &amp;nbsp;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 20:14:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Subset-a-list-using-various-conditions/m-p/33208#M19802</guid>
      <dc:creator>terapin</dc:creator>
      <dc:date>2016-12-07T20:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Subset a list using various conditions</title>
      <link>https://community.jmp.com/t5/Discussions/Subset-a-list-using-various-conditions/m-p/33212#M19803</link>
      <description>&lt;P&gt;What do you mean by "forward and backward evaluation?" Anything is possible in a JMP script!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 20:20:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Subset-a-list-using-various-conditions/m-p/33212#M19803</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2016-12-07T20:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: Subset a list using various conditions</title>
      <link>https://community.jmp.com/t5/Discussions/Subset-a-list-using-various-conditions/m-p/33232#M19812</link>
      <description>&lt;PRE&gt;Mark, &lt;BR /&gt;&lt;BR /&gt;Something like the following&lt;BR /&gt;&lt;BR /&gt;ma_date_list = {};&lt;BR /&gt;&lt;BR /&gt;For( i = 2, i &amp;lt;= N Items( ma_list ), i++,&lt;BR /&gt; If ( ma_list[i] &amp;gt; 0 &amp;amp; ma_list[i-1] == 0 &amp;amp; ma_list[i-2] == 0 &amp;amp; ma_list[i-3] == 0,&lt;BR /&gt; // then&lt;BR /&gt; ma_date_list = :Date[ma_row_list]&lt;BR /&gt; )&lt;BR /&gt;);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 22:01:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Subset-a-list-using-various-conditions/m-p/33232#M19812</guid>
      <dc:creator>terapin</dc:creator>
      <dc:date>2016-12-07T22:01:48Z</dc:date>
    </item>
  </channel>
</rss>

