<?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: JMP script question: how to divide one column by another in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JMP-script-question-how-to-divide-one-column-by-another/m-p/43888#M25326</link>
    <description>&lt;P&gt;As a new scripter the best thing you can do is struggle through a small project like this. &amp;nbsp;You are also asking for quite a bit in this post, so wasn't sure which question to answer. &amp;nbsp;I decided to just help you get started, so I've provided the small script below that should get you going in the right direction. &amp;nbsp;It has a small user interface and takes the information and adds a new column. &amp;nbsp;Hope it helps!&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 = current data table();
colNames = dt &amp;lt;&amp;lt; Get Column Names(String);

NW = New Window("Convert to m%",
	vlistbox(
		text box("Pick a column!"),
		cb = combo box(colNames),
		text box("Pick another column!"),
		cb2 = combo box(colNames),
		ok = button box("OK", 
			col = cb &amp;lt;&amp;lt; Get Selected;
			col2 = cb2 &amp;lt;&amp;lt; Get Selected;
			run();
		)
	)
);

run = function({},
	col1 = Column(dt, col);
	col2 = Column(dt, col2);
	dt &amp;lt;&amp;lt; New Column("m% for " || col, Numeric, Continuous, Formula(col1[] - col2[]));
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 31 Aug 2017 15:16:27 GMT</pubDate>
    <dc:creator>msharp</dc:creator>
    <dc:date>2017-08-31T15:16:27Z</dc:date>
    <item>
      <title>JMP script question: how to divide one column by another</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-script-question-how-to-divide-one-column-by-another/m-p/43832#M25319</link>
      <description>&lt;P&gt;Dear all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a regular user of JMP but new to Script. I am exporting data from a manufacturing system (SAP) and I would like to convert the kilogram figures that it outputs into %m figures. I am able to do this manually, however it is very time consuming so would like to write a script to do this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The user will need to input the following at the begining for the script to work:&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Select which columns are required to convert into %m&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Select which column (for each row) represents the total mass figure&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g. if we have a + b + c = d&amp;nbsp;&lt;/P&gt;&lt;P&gt;a, b and c will need to convert to %m and d will be the total mass figure&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example attached&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the new column name, I would like the user to write this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone can directly help, or point me in the right direction to do this I would be very appreciative.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dipesh&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 09:22:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-script-question-how-to-divide-one-column-by-another/m-p/43832#M25319</guid>
      <dc:creator>Dipesh</dc:creator>
      <dc:date>2017-08-31T09:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: JMP script question: how to divide one column by another</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-script-question-how-to-divide-one-column-by-another/m-p/43888#M25326</link>
      <description>&lt;P&gt;As a new scripter the best thing you can do is struggle through a small project like this. &amp;nbsp;You are also asking for quite a bit in this post, so wasn't sure which question to answer. &amp;nbsp;I decided to just help you get started, so I've provided the small script below that should get you going in the right direction. &amp;nbsp;It has a small user interface and takes the information and adds a new column. &amp;nbsp;Hope it helps!&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 = current data table();
colNames = dt &amp;lt;&amp;lt; Get Column Names(String);

NW = New Window("Convert to m%",
	vlistbox(
		text box("Pick a column!"),
		cb = combo box(colNames),
		text box("Pick another column!"),
		cb2 = combo box(colNames),
		ok = button box("OK", 
			col = cb &amp;lt;&amp;lt; Get Selected;
			col2 = cb2 &amp;lt;&amp;lt; Get Selected;
			run();
		)
	)
);

run = function({},
	col1 = Column(dt, col);
	col2 = Column(dt, col2);
	dt &amp;lt;&amp;lt; New Column("m% for " || col, Numeric, Continuous, Formula(col1[] - col2[]));
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Aug 2017 15:16:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-script-question-how-to-divide-one-column-by-another/m-p/43888#M25326</guid>
      <dc:creator>msharp</dc:creator>
      <dc:date>2017-08-31T15:16:27Z</dc:date>
    </item>
  </channel>
</rss>

