<?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 How to filter a list based on another list in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-filter-a-list-based-on-another-list/m-p/39308#M22987</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;it should be easy but I cannot figure out by myself.&lt;/P&gt;&lt;P&gt;I have 2 lists and I would like to filter the first 1 based on the second&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;ColList --&amp;gt; contain my table column names&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;CompList --&amp;gt; contain extractant&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;For example&amp;nbsp;&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ColList = ("aa_Lio", "aa_Leo", "ab_Lio", "ab_Leo", "ac_Lio", "ac_Leo", "ad_Lio", "ad_Leo"&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;CompList = ("Lio")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Goal&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;create a list which I call&amp;nbsp;extractCol whichwould&amp;nbsp;be in my example&amp;nbsp;extractCol =&amp;nbsp;("aa_Lio", "ab_Lio", "ac_Lio", "ad_Lio")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;here is my script. If i dont use the For loop it works ...&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;For( k = 1, k &amp;lt;= 1, k++,&lt;BR /&gt;&amp;nbsp; For( i = 1, i &amp;lt;= 3, i++,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; If( Contains( ColList[i], CompList[k]) &amp;gt;=1&amp;nbsp;,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Insert Into( extractCol, ColList[i] )&lt;BR /&gt;&amp;nbsp; &amp;nbsp; )&lt;BR /&gt;&amp;nbsp; );&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Lionel&lt;/P&gt;</description>
    <pubDate>Wed, 17 May 2017 08:54:27 GMT</pubDate>
    <dc:creator>KinKame</dc:creator>
    <dc:date>2017-05-17T08:54:27Z</dc:date>
    <item>
      <title>How to filter a list based on another list</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-filter-a-list-based-on-another-list/m-p/39308#M22987</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;it should be easy but I cannot figure out by myself.&lt;/P&gt;&lt;P&gt;I have 2 lists and I would like to filter the first 1 based on the second&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;ColList --&amp;gt; contain my table column names&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;CompList --&amp;gt; contain extractant&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;For example&amp;nbsp;&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ColList = ("aa_Lio", "aa_Leo", "ab_Lio", "ab_Leo", "ac_Lio", "ac_Leo", "ad_Lio", "ad_Leo"&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;CompList = ("Lio")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Goal&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;create a list which I call&amp;nbsp;extractCol whichwould&amp;nbsp;be in my example&amp;nbsp;extractCol =&amp;nbsp;("aa_Lio", "ab_Lio", "ac_Lio", "ad_Lio")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;here is my script. If i dont use the For loop it works ...&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;For( k = 1, k &amp;lt;= 1, k++,&lt;BR /&gt;&amp;nbsp; For( i = 1, i &amp;lt;= 3, i++,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; If( Contains( ColList[i], CompList[k]) &amp;gt;=1&amp;nbsp;,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Insert Into( extractCol, ColList[i] )&lt;BR /&gt;&amp;nbsp; &amp;nbsp; )&lt;BR /&gt;&amp;nbsp; );&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Lionel&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 08:54:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-filter-a-list-based-on-another-list/m-p/39308#M22987</guid>
      <dc:creator>KinKame</dc:creator>
      <dc:date>2017-05-17T08:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter a list based on another list</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-filter-a-list-based-on-another-list/m-p/39309#M22988</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NamesDefaultToHere(1);

ColList = {"aa_Lio", "aa_Leo", "ab_Lio", "ab_Leo", "ac_Lio", "ac_Leo", "ad_Lio", "ad_Leo" };
CompList = {"Lio"};

extractCol = {};
for(k=1, k&amp;lt;=NItems(CompList), k++,
	for(i=1, i&amp;lt;=NItems(ColList), i++,
		if(EndsWith(ColList[i], CompList[k]), InsertInto(extractCol, colList[i]));
	);
);
extractCol;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 May 2017 09:09:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-filter-a-list-based-on-another-list/m-p/39309#M22988</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2017-05-17T09:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter a list based on another list</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-filter-a-list-based-on-another-list/m-p/39342#M23004</link>
      <description>Ian&lt;BR /&gt;thank you,&lt;BR /&gt;the EndsWith function works perfectly ...&lt;BR /&gt;best regards&lt;BR /&gt;Lionel</description>
      <pubDate>Thu, 18 May 2017 02:42:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-filter-a-list-based-on-another-list/m-p/39342#M23004</guid>
      <dc:creator>KinKame</dc:creator>
      <dc:date>2017-05-18T02:42:13Z</dc:date>
    </item>
  </channel>
</rss>

