<?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: Help with contains within if else in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Help-with-contains-within-if-else/m-p/91507#M38749</link>
    <description>&lt;P&gt;There's no obvious mistake in your code. We'll need some more details to help figure where the confusion is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example showing that your prototype is correct.&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;dts = {"$SAMPLE_DATA\Fitness.jmp", "$SAMPLE_DATA\Big Class.jmp"}; 
 
For( i = 1, i &amp;lt;= N Items( dts ), i++,
	dtNext = Open( dts[i] );
	Summarize( dtNext, testlist = By( :age ) );

	Show( testlist );

	If( Contains( testlist, "42" ), 

		Show( "testlist contains 42" );
	
	, //else
 
		Show( "testlist doesn't contain 42" )
	);
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The log:&lt;/P&gt;
&lt;PRE&gt;/*:

testlist = {"38", "40", "42", "43", "44", "45", "47", "48", "49", "50", "51", "52", "54", "57"};
"testlist contains 42";
testlist = {"12", "13", "14", "15", "16", "17"};
"testlist doesn't contain 42";&lt;/PRE&gt;</description>
    <pubDate>Fri, 04 Jan 2019 17:50:32 GMT</pubDate>
    <dc:creator>Jeff_Perkinson</dc:creator>
    <dc:date>2019-01-04T17:50:32Z</dc:date>
    <item>
      <title>Help with contains within if else</title>
      <link>https://community.jmp.com/t5/Discussions/Help-with-contains-within-if-else/m-p/91466#M38748</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have written the following piece of code which checks if/not a list contains a character and performs some steps accordingly.&lt;/P&gt;
&lt;P&gt;For some reason, the script doesnt check for "if contains" condition and always executes the else part.I think I have a silly mistake here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Clear Symbols();
Delete Symbols();
clear globals();
 
 

dtNext = Open("C:\temp\output.csv","invisible");
Summarize(dtNext, testlist = By(:test));
show(testlist );
SAVEPATH = "C:\temp\";
If(contains(testlist ,"M"),

Macrodt=New Table("test_type",
New Column("test_type",
Character,
Nominal,
Set Values( {"Morning"})
),
invisible
);




, //else
Macrodt=New Table("test_type",
New Column("test_type",
Character,
Nominal,
Set Values( {"Evening"})
),
invisible
);
);

//Save macro file
Macrodt&amp;lt;&amp;lt;Save(SAVEPATH||"test_type.csv");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2019 17:40:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-with-contains-within-if-else/m-p/91466#M38748</guid>
      <dc:creator>ENTHU</dc:creator>
      <dc:date>2019-01-04T17:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: Help with contains within if else</title>
      <link>https://community.jmp.com/t5/Discussions/Help-with-contains-within-if-else/m-p/91507#M38749</link>
      <description>&lt;P&gt;There's no obvious mistake in your code. We'll need some more details to help figure where the confusion is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example showing that your prototype is correct.&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;dts = {"$SAMPLE_DATA\Fitness.jmp", "$SAMPLE_DATA\Big Class.jmp"}; 
 
For( i = 1, i &amp;lt;= N Items( dts ), i++,
	dtNext = Open( dts[i] );
	Summarize( dtNext, testlist = By( :age ) );

	Show( testlist );

	If( Contains( testlist, "42" ), 

		Show( "testlist contains 42" );
	
	, //else
 
		Show( "testlist doesn't contain 42" )
	);
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The log:&lt;/P&gt;
&lt;PRE&gt;/*:

testlist = {"38", "40", "42", "43", "44", "45", "47", "48", "49", "50", "51", "52", "54", "57"};
"testlist contains 42";
testlist = {"12", "13", "14", "15", "16", "17"};
"testlist doesn't contain 42";&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Jan 2019 17:50:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-with-contains-within-if-else/m-p/91507#M38749</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2019-01-04T17:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: Help with contains within if else</title>
      <link>https://community.jmp.com/t5/Discussions/Help-with-contains-within-if-else/m-p/92084#M38755</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6878"&gt;@Jeff_Perkinson&lt;/a&gt;&amp;nbsp;suggests, more info would help, but I'll take a stab at what I think may be a source of confusion for you. The "Contains" function can be used on a list OR a string... if you are looking for whether any list item contains a specific character, your "If" statement will not produce the desired result as written. If that is your intent, you&amp;nbsp;could surround your "testlist" variable with the Concat Items function in the "If" statement, i.e. Concat Items(testlist) evaluates to a single string made up of all of the list items stitched&amp;nbsp;together. Now the Contains function will return a positive response when looking for a specific character if it exists in the new string.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2019 19:21:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-with-contains-within-if-else/m-p/92084#M38755</guid>
      <dc:creator>jerry_cooper</dc:creator>
      <dc:date>2019-01-04T19:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Help with contains within if else</title>
      <link>https://community.jmp.com/t5/Discussions/Help-with-contains-within-if-else/m-p/92892#M38762</link>
      <description>I used cocncatitems function and it worked.&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Jan 2019 22:51:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-with-contains-within-if-else/m-p/92892#M38762</guid>
      <dc:creator>ENTHU</dc:creator>
      <dc:date>2019-01-04T22:51:37Z</dc:date>
    </item>
  </channel>
</rss>

