<?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 do I scale columns by another column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-scale-columns-by-another-column/m-p/628941#M82720</link>
    <description>&lt;P&gt;Hi there, I have a table that looks like this, a few nominal columns and then lots of numerical columns&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SeasonalOwl962_1-1683284713932.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/52582i09BB332583296B21/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SeasonalOwl962_1-1683284713932.png" alt="SeasonalOwl962_1-1683284713932.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I want to make a new "table_scaled" that has the nominal columns copied over and the N(#) columns divided by the "N rows" column and *100 to get a %. I'm trying this code but I'm only getting an empty new table with one blank column, any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();

NewTable("HOT_COLD_summary_scaled",
    For( i = 1, i &amp;lt;= N Cols( HOT_COLD_summary ), i++,
        dt &amp;lt;&amp;lt; New Column(
            Column( i ) &amp;lt;&amp;lt; get name,
            Numeric,
            "Continuous",
            Formula( (:column( i )*100) /(HOT_COLD_summary:N rows)  )
        )
    )
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 11 Jun 2023 00:00:59 GMT</pubDate>
    <dc:creator>SeasonalOwl962</dc:creator>
    <dc:date>2023-06-11T00:00:59Z</dc:date>
    <item>
      <title>How do I scale columns by another column</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-scale-columns-by-another-column/m-p/628941#M82720</link>
      <description>&lt;P&gt;Hi there, I have a table that looks like this, a few nominal columns and then lots of numerical columns&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SeasonalOwl962_1-1683284713932.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/52582i09BB332583296B21/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SeasonalOwl962_1-1683284713932.png" alt="SeasonalOwl962_1-1683284713932.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I want to make a new "table_scaled" that has the nominal columns copied over and the N(#) columns divided by the "N rows" column and *100 to get a %. I'm trying this code but I'm only getting an empty new table with one blank column, any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();

NewTable("HOT_COLD_summary_scaled",
    For( i = 1, i &amp;lt;= N Cols( HOT_COLD_summary ), i++,
        dt &amp;lt;&amp;lt; New Column(
            Column( i ) &amp;lt;&amp;lt; get name,
            Numeric,
            "Continuous",
            Formula( (:column( i )*100) /(HOT_COLD_summary:N rows)  )
        )
    )
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 00:00:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-scale-columns-by-another-column/m-p/628941#M82720</guid>
      <dc:creator>SeasonalOwl962</dc:creator>
      <dc:date>2023-06-11T00:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scale columns by another column</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-scale-columns-by-another-column/m-p/628989#M82723</link>
      <description>&lt;P&gt;Could you provide an example with correct values on how you want the final table to look like? Also can provide the data table which could be used for developing the script (remove source script and anonymize if needed) as picture of table cannot be used for that.&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2023 13:30:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-scale-columns-by-another-column/m-p/628989#M82723</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-05-05T13:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scale columns by another column</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-scale-columns-by-another-column/m-p/629011#M82724</link>
      <description>&lt;P&gt;Hi Jarmo,&lt;/P&gt;&lt;P&gt;Thanks, sure thing. I've attached summary which is the starting table and summary_scaled is what I'd like to script.&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2023 14:03:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-scale-columns-by-another-column/m-p/629011#M82724</guid>
      <dc:creator>SeasonalOwl962</dc:creator>
      <dc:date>2023-05-05T14:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I scale columns by another column</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-scale-columns-by-another-column/m-p/629162#M82734</link>
      <description>&lt;P&gt;If you have JMP16+ here is one option&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$DOWNLOADS/summary.jmp");
dt_copy = dt &amp;lt;&amp;lt; Subset(All Rows, Selected Columns(0), Output table("summary_scaled"));
close(dt, no save);

col_list = dt_copy &amp;lt;&amp;lt; Get Column Names("String");
// first col isn't needed, second col is expected to be N Rows -&amp;gt; skip those

cols_of_interest = Remove(col_list, 1,2);

For Each({ncol}, cols_of_interest,
	new_col = Eval(EvalExpr(
		dt_copy &amp;lt;&amp;lt; New Column(ncol ||"_scaled%", Numeric, Continuous, Formula(
			100*Expr(Name Expr(AsColumn(ncol))) / :"N Rows"n
		))
	));
	dt_copy &amp;lt;&amp;lt; Move Selected Columns({new_col}, after(Eval(ncol)))
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;If you have older JMP you will have to replace For Each with For loop.&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2023 16:00:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-scale-columns-by-another-column/m-p/629162#M82734</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-05-05T16:00:06Z</dc:date>
    </item>
  </channel>
</rss>

