<?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: Select column name using contains function in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Select-column-name-using-contains-function/m-p/58984#M32482</link>
    <description>&lt;P&gt;there might be a couple of things going on.&lt;/P&gt;
&lt;P&gt;One posibility is that a column is selected before the script runs?&lt;/P&gt;
&lt;P&gt;Try adding this to the beginning of your script, right after dt is defined.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; Clear Selection;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 31 May 2018 23:42:37 GMT</pubDate>
    <dc:creator>Byron_JMP</dc:creator>
    <dc:date>2018-05-31T23:42:37Z</dc:date>
    <item>
      <title>Select column name using contains function</title>
      <link>https://community.jmp.com/t5/Discussions/Select-column-name-using-contains-function/m-p/58701#M32420</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I like to select multiple columns that have names contains a string. I tried below script and no error but the columns does not get selected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;col_list = dt3 &amp;lt;&amp;lt; get column names(string);
for( i = 1, i &amp;lt;= N Items( col_list ), i++,
If(Contains( col_list[i], "A_B_C" ),
Column(col_list[i] ) &amp;lt;&amp;lt; Set Selected (1)
)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I check col_list, it has all the colums in entire data table. I appreciate your help. Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 17:07:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-column-name-using-contains-function/m-p/58701#M32420</guid>
      <dc:creator>AT</dc:creator>
      <dc:date>2018-05-30T17:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: Select column name using contains function</title>
      <link>https://community.jmp.com/t5/Discussions/Select-column-name-using-contains-function/m-p/58704#M32422</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/10363"&gt;@AT&lt;/a&gt;,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;I think you have the Contains() arguments inverted.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table(); 

Col_List = dt &amp;lt;&amp;lt; Get Column Names("String"); 

for(i = 1, i &amp;lt;= N Items(Col_List),i++,
		If(Contains("A_B_C",Col_List[i]),
			Column(Col_List[i]) &amp;lt;&amp;lt; Set Selected(1);
		  );
   );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/10917i718D3E335BA011A8/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 17:03:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-column-name-using-contains-function/m-p/58704#M32422</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2018-05-30T17:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Select column name using contains function</title>
      <link>https://community.jmp.com/t5/Discussions/Select-column-name-using-contains-function/m-p/58718#M32426</link>
      <description>&lt;P&gt;Thanks. I tried your script but with differer example and I still have an issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Names Default To Here( 1 );&lt;BR /&gt;dt = Current Data Table();&lt;/P&gt;&lt;P&gt;Col_List = dt &amp;lt;&amp;lt; Get Column Names("String");&lt;/P&gt;&lt;P&gt;for(i = 1, i &amp;lt;= N Items(Col_List),i++,&lt;BR /&gt;If(Contains("A_B_C",Col_List[i]),&lt;BR /&gt;Column(Col_List[i]) &amp;lt;&amp;lt; Set Selected(1);&lt;BR /&gt;);&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The columns A_B_C and A is selcted. I don't understand why. I appreciate your help. I have attached the image result.&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 17:52:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-column-name-using-contains-function/m-p/58718#M32426</guid>
      <dc:creator>AT</dc:creator>
      <dc:date>2018-05-30T17:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Select column name using contains function</title>
      <link>https://community.jmp.com/t5/Discussions/Select-column-name-using-contains-function/m-p/58984#M32482</link>
      <description>&lt;P&gt;there might be a couple of things going on.&lt;/P&gt;
&lt;P&gt;One posibility is that a column is selected before the script runs?&lt;/P&gt;
&lt;P&gt;Try adding this to the beginning of your script, right after dt is defined.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; Clear Selection;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 May 2018 23:42:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-column-name-using-contains-function/m-p/58984#M32482</guid>
      <dc:creator>Byron_JMP</dc:creator>
      <dc:date>2018-05-31T23:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: Select column name using contains function</title>
      <link>https://community.jmp.com/t5/Discussions/Select-column-name-using-contains-function/m-p/59000#M32489</link>
      <description>&lt;P&gt;The Contains() function takes the 2nd argument and looks into the 1st argument to see if the 2nd argument's value can be found in the first argument.&amp;nbsp; Therefore, if the Contains() function is&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Contains("A_B_C", Col_List[i])&lt;/P&gt;
&lt;P&gt;and the value of Col_List[i] = "A_B_C" it will take the value "A_B_C" and look into the first arguement to see if it can be found.&amp;nbsp; Which it can, because the first arguement contains "A_B_C".&amp;nbsp; Now if the column name is "A", and you do the same comparison, the Contains() function will take the 2nd arguement, "A" and look into the 1st arguement, "A_B_C" and it will find that an "A" is in the first arguement, and therefore it will be a true comparison.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thus, the original form of the Contains() function is what is wanted&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

Col_List = dt &amp;lt;&amp;lt; Get Column Names("String");

for(i = 1, i &amp;lt;= N Items(Col_List),i++,
If(Contains(Col_List[i], "A_B_C"),
Column(Col_List[i]) &amp;lt;&amp;lt; Set Selected(1);
);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Jun 2018 03:04:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-column-name-using-contains-function/m-p/59000#M32489</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-06-01T03:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Select column name using contains function</title>
      <link>https://community.jmp.com/t5/Discussions/Select-column-name-using-contains-function/m-p/59066#M32498</link>
      <description>&lt;P&gt;Thanks Jim for your help. It works well now.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 16:19:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-column-name-using-contains-function/m-p/59066#M32498</guid>
      <dc:creator>AT</dc:creator>
      <dc:date>2018-06-01T16:19:44Z</dc:date>
    </item>
  </channel>
</rss>

