<?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 count for a set of items across columns in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-count-for-a-set-of-items-across-columns/m-p/565495#M77763</link>
    <description>&lt;P&gt;Thanks &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
    <pubDate>Sun, 06 Nov 2022 22:36:05 GMT</pubDate>
    <dc:creator>Vins</dc:creator>
    <dc:date>2022-11-06T22:36:05Z</dc:date>
    <item>
      <title>How to count for a set of items across columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-count-for-a-set-of-items-across-columns/m-p/563852#M77657</link>
      <description>&lt;P&gt;Hi JMP staff and experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a simple issue I think JSL would be the best approach, but I do not know how to code in JSL. I should probably find time and learn!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, I have a list of items, "Tea", "Eggs", "Bread", "Milk" etc. Each item appears alone in a column, and the number of columns can vary but would be fixed in a particular table instance. Each row represents an independent observation of items. A specific item can appear in any column, in any row but only once in a row or not appear at all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to use a JSL script to indicate in a new column wether a particular set of items (say "Tea", "Milk", "Bread") exist in a particular row or not. Order of occurrence in a row does not matter. However, the set of items I am counting have to all appear. &amp;nbsp;I hope to use this JSL as a template to modify and query for the occurrence of sets of items in tables with rows of upto 10000. Eventually I would like to derive stats such as: 10% of the entries have "Tea" &amp;amp; "Bacon", 5% have&amp;nbsp;"Tea", "Milk", "Yoghurt" etc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a JMP platform that can do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached is an example dataset.&lt;/P&gt;&lt;P&gt;Many thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 00:56:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-count-for-a-set-of-items-across-columns/m-p/563852#M77657</guid>
      <dc:creator>Vins</dc:creator>
      <dc:date>2023-06-09T00:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to count for a set of items across columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-count-for-a-set-of-items-across-columns/m-p/563910#M77659</link>
      <description>&lt;P&gt;Here is a formula that will place a 1 in the indicator column if the combination of Bread and Yoghurt are found in a given row, and a 0 if not found&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
itemList = dt[Row(), Index( 1, 5 )];
If( Contains( itemList, "Bread" ) &amp;amp; Contains( itemList, "Yoghurt" ),
	1,
	0
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 02:11:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-count-for-a-set-of-items-across-columns/m-p/563910#M77659</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-11-03T02:11:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to count for a set of items across columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-count-for-a-set-of-items-across-columns/m-p/564100#M77663</link>
      <description>&lt;P&gt;Here is one option &lt;A href="https://www.jmp.com/support/help/en/16.2/#page/jmp/associative-arrays-in-set-operations.shtml#" target="_blank" rel="noopener"&gt;using associative arrays and their set operations&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$DOWNLOADS/items.jmp");

list_to_search_for =  {"Tea", "Milk", "Bread"};
aa_mask = Associative Array(list_to_search_for);

dt &amp;lt;&amp;lt; New Column("Match", Numeric, Continuous, &amp;lt;&amp;lt; Set Each Value(
	aa_row = Associative Array(dt[Row(), 0]);
	temp_mask = aa_mask;
	temp_mask &amp;lt;&amp;lt; Remove(aa_row);
	If(N Items(temp_mask) == 0,
		1
	,
		0
	);
));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1667457266928.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/46848i699111A85A6C3C9C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1667457266928.png" alt="jthi_1-1667457266928.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;JMP's&amp;nbsp;&lt;A href="https://www.jmp.com/support/help/en/16.2/#page/jmp/introduction-to-consumer-research.shtml#ww156233" target="_blank" rel="noopener"&gt;Consumer Research platform&lt;/A&gt;&amp;nbsp;might also be helpful but I haven't used it so I'm not sure if it can look for such combinations as you need (Conditional Association might be helpful?)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1667457046437.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/46847iC6DA31DC9B633E66/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1667457046437.png" alt="jthi_0-1667457046437.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 06:34:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-count-for-a-set-of-items-across-columns/m-p/564100#M77663</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-11-03T06:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to count for a set of items across columns</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-count-for-a-set-of-items-across-columns/m-p/565495#M77763</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
      <pubDate>Sun, 06 Nov 2022 22:36:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-count-for-a-set-of-items-across-columns/m-p/565495#M77763</guid>
      <dc:creator>Vins</dc:creator>
      <dc:date>2022-11-06T22:36:05Z</dc:date>
    </item>
  </channel>
</rss>

