<?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 multiply rows with the same properties in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-multiply-rows-with-the-same-properties/m-p/756240#M93813</link>
    <description>&lt;P&gt;You want to have something like this?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1716206861736.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/64400iE079AFB04D1BBF51/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1716206861736.png" alt="jthi_0-1716206861736.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This is one fairly easy option&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(5),
	Compress File When Saved(1),
	New Column("A", Character, "Nominal", Set Values({"E", "E", "E", "E", "E"})),
	New Column("B", Character, "Nominal", Set Values({"L", "C", "L", "L", "C"})),
	New Column("C",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([5, 7, 10, 50, 7])
	)
);

aa = Associative Array();

For Each Row(dt,
	name = :A || :B;
	If(!Contains(aa, name),
		aa[name] = 1;
	);
	Multiply To(aa[name], :C);
);

newcol = dt &amp;lt;&amp;lt; New Column("R", Numeric, Continuous, Formula(
	aa[:A || :B];
));
dt &amp;lt;&amp;lt; run formulas;
newcol &amp;lt;&amp;lt; delete formula;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 20 May 2024 12:08:18 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2024-05-20T12:08:18Z</dc:date>
    <item>
      <title>How to multiply rows with the same properties</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-multiply-rows-with-the-same-properties/m-p/756094#M93812</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to multiply certain rows based on their other properties. For example, I want to multiply the chance of having the same first and last name.&lt;/P&gt;&lt;P&gt;How can I do this in code?&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2024 11:49:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-multiply-rows-with-the-same-properties/m-p/756094#M93812</guid>
      <dc:creator>Liranlev</dc:creator>
      <dc:date>2024-05-20T11:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to multiply rows with the same properties</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-multiply-rows-with-the-same-properties/m-p/756240#M93813</link>
      <description>&lt;P&gt;You want to have something like this?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1716206861736.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/64400iE079AFB04D1BBF51/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1716206861736.png" alt="jthi_0-1716206861736.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This is one fairly easy option&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(5),
	Compress File When Saved(1),
	New Column("A", Character, "Nominal", Set Values({"E", "E", "E", "E", "E"})),
	New Column("B", Character, "Nominal", Set Values({"L", "C", "L", "L", "C"})),
	New Column("C",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([5, 7, 10, 50, 7])
	)
);

aa = Associative Array();

For Each Row(dt,
	name = :A || :B;
	If(!Contains(aa, name),
		aa[name] = 1;
	);
	Multiply To(aa[name], :C);
);

newcol = dt &amp;lt;&amp;lt; New Column("R", Numeric, Continuous, Formula(
	aa[:A || :B];
));
dt &amp;lt;&amp;lt; run formulas;
newcol &amp;lt;&amp;lt; delete formula;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 May 2024 12:08:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-multiply-rows-with-the-same-properties/m-p/756240#M93813</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-05-20T12:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to multiply rows with the same properties</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-multiply-rows-with-the-same-properties/m-p/756245#M93814</link>
      <description>&lt;P&gt;My reading of&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/57311"&gt;@Liranlev&lt;/a&gt;&amp;nbsp;is different from Jarmo's.&amp;nbsp; I read the request as to be able to take the values of chance in rows 1 &amp;amp; 3 and multiply them together and place them in row 7, and take the value of row 7 and place them in row 8.&amp;nbsp; This seems to be treating a JMP table as one might do this in Excel, but that aside, the script below will create the table.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1716208691013.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/64401i8601B0BF4EC3BD48/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1716208691013.png" alt="txnelson_0-1716208691013.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = New Table("Untitled",
	Add Rows(5),
	Compress File When Saved(1),
	New Column("A", Character, "Nominal", Set Values({"E", "E", "E", "E", "E"})),
	New Column("B", Character, "Nominal", Set Values({"L", "C", "L", "L", "C"})),
	New Column("C",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([5, 7, 10, 50, 7])
	)
);

aa = Associative Array();

For Each Row(dt,
	name = :A || :B;
	If(!Contains(aa, name),
		aa[name] = 1;
	);
	Multiply To(aa[name], :C);
);

newcol = dt &amp;lt;&amp;lt; New Column("R", Numeric, Continuous, Formula(
	aa[:A || :B];
));
dt &amp;lt;&amp;lt; run formulas;
newcol &amp;lt;&amp;lt; delete formula;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 May 2024 12:39:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-multiply-rows-with-the-same-properties/m-p/756245#M93814</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-05-20T12:39:23Z</dc:date>
    </item>
  </channel>
</rss>

