<?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 find a specific text (word) within a column character - nominal data type ? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-find-a-specific-text-word-within-a-column-character/m-p/259628#M50963</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to get some help on finding a specific string (actually 2 strings, say "JMP1" and "JMP2") that may be within a column with text, as we move down that column, and then have a formula column next to it to label "JMP1" or "JMP2", if it finds it, or label say "NA" otherwise.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A couple of notes:&lt;/P&gt;&lt;P&gt;1-&amp;nbsp;"JMP1" or "JMP2" can be in any position within the text in Column 1&lt;/P&gt;&lt;P&gt;2- "JMP1" and "JMP2" are not contained in the same text in Column 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So in my mind it will be something like this for the Formula Column (Column 2 - the label column):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IF (Column 1 &lt;EM&gt;contains&lt;/EM&gt; "JMP1", then Column 2 = "JMP1", else (IF Column 1 &lt;EM&gt;contains&lt;/EM&gt; "JMP2", then Column 2 = "JMP2", else Column 2 = "NA"));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I looked up to the Match function, but I got a bit confused with the multiple arguments and expressions. Maybe I'm not on the right track either, hence why I need advice&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It will be great if someone could share their thoughts (preferably through the Formulas area, but will be open to suggestions through JSL).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vasco&lt;/P&gt;</description>
    <pubDate>Tue, 21 Apr 2020 23:43:19 GMT</pubDate>
    <dc:creator>VCO</dc:creator>
    <dc:date>2020-04-21T23:43:19Z</dc:date>
    <item>
      <title>How to find a specific text (word) within a column character - nominal data type ?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-find-a-specific-text-word-within-a-column-character/m-p/259628#M50963</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to get some help on finding a specific string (actually 2 strings, say "JMP1" and "JMP2") that may be within a column with text, as we move down that column, and then have a formula column next to it to label "JMP1" or "JMP2", if it finds it, or label say "NA" otherwise.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A couple of notes:&lt;/P&gt;&lt;P&gt;1-&amp;nbsp;"JMP1" or "JMP2" can be in any position within the text in Column 1&lt;/P&gt;&lt;P&gt;2- "JMP1" and "JMP2" are not contained in the same text in Column 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So in my mind it will be something like this for the Formula Column (Column 2 - the label column):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IF (Column 1 &lt;EM&gt;contains&lt;/EM&gt; "JMP1", then Column 2 = "JMP1", else (IF Column 1 &lt;EM&gt;contains&lt;/EM&gt; "JMP2", then Column 2 = "JMP2", else Column 2 = "NA"));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I looked up to the Match function, but I got a bit confused with the multiple arguments and expressions. Maybe I'm not on the right track either, hence why I need advice&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It will be great if someone could share their thoughts (preferably through the Formulas area, but will be open to suggestions through JSL).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vasco&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 23:43:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-find-a-specific-text-word-within-a-column-character/m-p/259628#M50963</guid>
      <dc:creator>VCO</dc:creator>
      <dc:date>2020-04-21T23:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a specific text (word) within a column character - nominal data type ?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-find-a-specific-text-word-within-a-column-character/m-p/259636#M50964</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( Contains( :name, "JA" ),
	"JA",
	If( Contains( :name, "MA" ),
		"MA",
		"NA"
	)
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I think you are there. &amp;nbsp;JMP has a character function called contains. &amp;nbsp;You can use that as illustrated above for the big class sample data file. See the help for character&amp;nbsp;functions at&amp;nbsp;&lt;A href="https://www.jmp.com/support/help/en/15.1/?os=mac&amp;amp;source=application&amp;amp;utm_source=helpmenu&amp;amp;utm_medium=application#page/jmp/character-functions.shtml#ww128307" target="_self"&gt;character function help&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 00:06:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-find-a-specific-text-word-within-a-column-character/m-p/259636#M50964</guid>
      <dc:creator>KarenC</dc:creator>
      <dc:date>2020-04-22T00:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a specific text (word) within a column character - nominal data type ?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-find-a-specific-text-word-within-a-column-character/m-p/259687#M50965</link>
      <description>&lt;P&gt;Regex is really powerful and used in a lot of languages. Though it can admittedly be quite hard to understand.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1);
dt = new table("Example", 
	New Column("JMPs", character, &amp;lt;&amp;lt;Set Values(repeat({"JMP1", "JMP2", "JMP14", "Something Else"}, 5)));
);

dt &amp;lt;&amp;lt; new Column("Simple Regex with Or", 
	character, 
	formula(
		// 14 needs to be first because JMP1 would also match
		r = regex(:JMPs, "JMP14|JMP1|JMP2");
		if(!ismissing(r), 
			r
		, // else
			"NA"
		)
	)
);

// a more compliated example
// if you know something about the form you can do some neat stuff

dt &amp;lt;&amp;lt; new Column("regex with pattern", 
	character, 
	formula(
		// this looks for "JMP" than any number of digits so you don't have to make a billion if statements
		r = regex(:JMPs, "JMP\d+");
		if(!ismissing(r), 
			r
		, // else
			"NA"
		)
	)
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Apr 2020 02:13:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-find-a-specific-text-word-within-a-column-character/m-p/259687#M50965</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2020-04-22T02:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a specific text (word) within a column character - nominal data type ?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-find-a-specific-text-word-within-a-column-character/m-p/259755#M50971</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/5815"&gt;@KarenC&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, it worked !&amp;nbsp; Simple and straightforward&amp;nbsp; :)&lt;/img&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I actually looked at the Contains function in the Character functions' help, but was getting confused with the description as it says that it will retrieve a "numeric position". Your solution was pretty much what I mentioned on my post, just had to converted into an actual JMP formula using the contains function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Vasco&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 08:46:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-find-a-specific-text-word-within-a-column-character/m-p/259755#M50971</guid>
      <dc:creator>VCO</dc:creator>
      <dc:date>2020-04-22T08:46:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a specific text (word) within a column character - nominal data type ?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-find-a-specific-text-word-within-a-column-character/m-p/259758#M50972</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2610"&gt;@vince_faller&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I must admit that your proposal is a bit too much advanced for me at this point.Thanks for your input., though&amp;nbsp; :)&lt;/img&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really liked Karen's simple proposal for my problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vasco&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 08:50:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-find-a-specific-text-word-within-a-column-character/m-p/259758#M50972</guid>
      <dc:creator>VCO</dc:creator>
      <dc:date>2020-04-22T08:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a specific text (word) within a column character - nominal data type ?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-find-a-specific-text-word-within-a-column-character/m-p/259815#M50982</link>
      <description>Ah, I see the confusion. So since we used the full string that you were looking for in the contains function we got either a "1" as the string started in position 1 or a 0 since the string didn't start in any position. This worked in the If statement. If we had used Contains(:column, "P") it would have returned "3" for any row with a JMPx value, since P is in the third position.  I didn't think (or really know) about that nuance as I typically use the contain function as you were trying to do...is something there or not.  The Regex solution is more sophisticated and is a good solution for something that is going to be used repeatability with changing data.</description>
      <pubDate>Wed, 22 Apr 2020 13:58:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-find-a-specific-text-word-within-a-column-character/m-p/259815#M50982</guid>
      <dc:creator>KarenC</dc:creator>
      <dc:date>2020-04-22T13:58:59Z</dc:date>
    </item>
  </channel>
</rss>

