<?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: How to get columns names that contains certain words given by user? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/83806#M37677</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am stuck with a similar problem.I need to check if the columns contain either of the 2 strings and then replace column value with value in another column.&lt;/P&gt;
&lt;P&gt;Here's the code -&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For(i=1,i&amp;lt;= NRows(dt),i++,
if(contains(:step[i],"NA")| contains(:step[i],".") ,
:step[i] = description[i];
)

);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I get an error saying -&amp;nbsp;argument is wrong type in access or evaluation of 'Contains'&lt;/P&gt;
&lt;P&gt;What am I doing wrong here?&lt;/P&gt;</description>
    <pubDate>Mon, 19 Nov 2018 19:57:45 GMT</pubDate>
    <dc:creator>ENTHU</dc:creator>
    <dc:date>2018-11-19T19:57:45Z</dc:date>
    <item>
      <title>How to get columns names that contains certain words given by user?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/19356#M17644</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking for advice regarding getting columns that contains certain words that I am interested in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For instance:&lt;/P&gt;
&lt;P&gt;I would like to get any column names that contains "Number" in the given sample data provided below. Expected returned list of columns names should be {"Flight Number" , "Tail Number"}. However, I am not able to get anything returned. My codes are as follows:&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;dt = open("$SAMPLE_DATA/Air Traffic.jmp");
a= "Number";
col=dt&amp;lt;&amp;lt;get column names(string);
nc=nitems(col);
xxx={};
for(i=1,i&amp;lt;=nc,i++,
  if(contains(col,a),
  insert into(xxx,i);
  );
);&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;Any help or advice will be greatly appreciated! Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 19:59:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/19356#M17644</guid>
      <dc:creator>ValarieSimmons</dc:creator>
      <dc:date>2018-11-19T19:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to get columns names that contains certain words given by user?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/19357#M17645</link>
      <description>&lt;P&gt;Remember 'col' will be a list. So try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0px; font-size: 14px; line-height: normal; font-family: Courier; color: #942193;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA/Air Traffic.jmp" );
a = "Number";
col = dt &amp;lt;&amp;lt; get column names( string );
nc = N Items( col );
xxx = {};
For( i = 1, i &amp;lt;= nc, i++,
If( Contains( col[i], a ),
Insert Into( xxx, col[i] )
)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P style="margin: 0px; font-size: 14px; line-height: normal; font-family: Courier;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0px; font-size: 14px; line-height: normal; font-family: Courier;"&gt;&lt;SPAN style="color: #032ce4;"&gt;Print&lt;/SPAN&gt;&lt;STRONG&gt;(&lt;/STRONG&gt; xxx &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;SPAN style="color: #011993;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 20:07:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/19357#M17645</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2018-11-19T20:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to get columns names that contains certain words given by user?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/19358#M17646</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, Ian!&lt;/P&gt;&lt;P&gt;Exactly the solution I'm looking for. &lt;SPAN __jive_emoticon_name="grin" __jive_macro_name="emoticon" class="jive_emote jive_macro" src="https://community.jmp.com/7.0.4.3b79b96/images/emoticons/grin.png"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Val&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jul 2016 03:48:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/19358#M17646</guid>
      <dc:creator>ValarieSimmons</dc:creator>
      <dc:date>2016-07-05T03:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to get columns names that contains certain words given by user?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/19359#M17647</link>
      <description>&lt;P&gt;Hi Ian &lt;A href="https://kvoqx44227.lithium.com/people/Ian@JMP" target="_blank"&gt;Ian@JMP&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An extension to what I was previously working on:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using the same data as the previous question, based on the selected words that I want from the available columns in data table "Air Traffic", I am expecting an output as shown below if the available columns in the data contains the words in the "SelectedNames" column at their respective rows:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="11978_pastedImage_2.png" style="width: 603px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/3370iA11D389DB30B9669/image-size/medium?v=v2&amp;amp;px=400" role="button" title="11978_pastedImage_2.png" alt="11978_pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However I am getting this error message in Log &amp;amp; no insertion of any correct column names in the second column:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="11979_pastedImage_3.png" style="width: 670px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/3371iC8F9356E16FBE190/image-size/medium?v=v2&amp;amp;px=400" role="button" title="11979_pastedImage_3.png" alt="11979_pastedImage_3.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="11980_pastedImage_4.png" style="width: 611px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/3372i6824ECC3296422FF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="11980_pastedImage_4.png" alt="11980_pastedImage_4.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These are my codes, can you help me to check what's wrong with them?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA/Air Traffic.jmp" );
a = {"Number", "Flight"};
col = dt &amp;lt;&amp;lt; get column names( string );
nc = N Items( col );
dt1 = New Table( "Table1" );
c1 = (dt1 &amp;lt;&amp;lt; New Column( "SelectedNames", character, set values( a ) )) &amp;lt;&amp;lt; get values;
dt1 &amp;lt;&amp;lt; New Column( "AvailableColumns", character );
xxx={};
For( j = 1, j &amp;lt;= N Items( c1 ), j++,
For( i = 1, i &amp;lt;= nc, i++,
If( Contains( col[i], a[j] ),
Insert Into( xxx, col[i] )
);
Column( dt1, 2 )[j] = Eval( xxx );
xxx = {};
);
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 19:59:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/19359#M17647</guid>
      <dc:creator>ValarieSimmons</dc:creator>
      <dc:date>2018-11-19T19:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to get columns names that contains certain words given by user?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/19360#M17648</link>
      <description>&lt;P&gt;You need to distinguish between a list and the type of items that it holds (which, in general, don't have to be homogenous). The error is due to the fact that you are trying to put list xxx (which happens to contain items that are all character), into a cell in a character column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The best way to do this will depend on what happens next in your code. I suspect that you might want to have 'AvaliableColumns' as an expression column, rather than a character column:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0px; font-size: 14px; line-height: normal; font-family: Courier; color: #942193;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA/Air Traffic.jmp" );
a = {"Number", "Flight"};
col = dt &amp;lt;&amp;lt; get column names( string );
nc = N Items( col );
dt1 = New Table( "Table1" );
c1 = (dt1 &amp;lt;&amp;lt; New Column( "SelectedNames", character, set values( a ) )) &amp;lt;&amp;lt; get values;
dt1 &amp;lt;&amp;lt; New Column( "AvailableColumns", expression );
For( j = 1, j &amp;lt;= N Items( c1 ), j++,
xxx = {};
For( i = 1, i &amp;lt;= nc, i++,
If( Contains( col[i], a[j] ), InsertInto(xxx, col[i]) );
);
Column( dt1, 2 )[j] =  xxx;
 
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P style="margin: 0px; font-size: 14px; line-height: normal; font-family: Courier;"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 19:58:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/19360#M17648</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2018-11-19T19:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to get columns names that contains certain words given by user?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/19361#M17649</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN __jive_emoticon_name="laugh" __jive_macro_name="emoticon" class="jive_macro_emoticon jive_emote jive_macro" src="https://community.jmp.com/7.0.4.3b79b96/images/emoticons/laugh.png"&gt;&lt;/SPAN&gt; Thanks again Ian.&lt;/P&gt;&lt;P&gt;Your solution works like a charm! &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_emote jive_macro" src="https://community.jmp.com/7.0.4.3b79b96/images/emoticons/happy.png"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Val&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jul 2016 09:52:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/19361#M17649</guid>
      <dc:creator>ValarieSimmons</dc:creator>
      <dc:date>2016-07-08T09:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to get columns names that contains certain words given by user?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/83806#M37677</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am stuck with a similar problem.I need to check if the columns contain either of the 2 strings and then replace column value with value in another column.&lt;/P&gt;
&lt;P&gt;Here's the code -&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For(i=1,i&amp;lt;= NRows(dt),i++,
if(contains(:step[i],"NA")| contains(:step[i],".") ,
:step[i] = description[i];
)

);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I get an error saying -&amp;nbsp;argument is wrong type in access or evaluation of 'Contains'&lt;/P&gt;
&lt;P&gt;What am I doing wrong here?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 19:57:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/83806#M37677</guid>
      <dc:creator>ENTHU</dc:creator>
      <dc:date>2018-11-19T19:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to get columns names that contains certain words given by user?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/83821#M37682</link>
      <description>&lt;P&gt;This is pretty different from the original thread.&amp;nbsp; I suggest creating a new topic.&amp;nbsp; Does your step column have a numeric data type?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 22:22:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/83821#M37682</guid>
      <dc:creator>cwillden</dc:creator>
      <dc:date>2018-11-19T22:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to get columns names that contains certain words given by user?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/83823#M37684</link>
      <description>&lt;P&gt;No.The column type is character.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 22:49:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-get-columns-names-that-contains-certain-words-given-by/m-p/83823#M37684</guid>
      <dc:creator>ENTHU</dc:creator>
      <dc:date>2018-11-19T22:49:28Z</dc:date>
    </item>
  </channel>
</rss>

