<?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 16: Script to add columns with formula, using relative reference in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JMP-16-Script-to-add-columns-with-formula-using-relative/m-p/423538#M67259</link>
    <description>&lt;P&gt;Thanks Mark! Worked like a charm!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did some tweaks, leaving it here for any future reference. Thanks alot!&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 );

// mock up user data table
dt = New Table( "Mock Up" );
For( c = 1, c &amp;lt; 6, c++,
	col = dt &amp;lt;&amp;lt; New Column( "My Column " || Char( c ), Numeric, Continuous );
	col &amp;lt;&amp;lt; Set Values( J( 25, 1, Random Normal( 80, 5 ) ) );
);
y = dt &amp;lt;&amp;lt; Get As Matrix;
col = dt &amp;lt;&amp;lt; New Column( "Total", Numeric, Continuous );
col &amp;lt;&amp;lt; Set Values( y * J( 5, 1, 1 ) );

// solution
dt = Current Data Table();
total = Column( N Col( dt ) ) &amp;lt;&amp;lt; Get As Matrix;
last c = N Col( dt );
For( c = 1, c &amp;lt; last c,  c++,
	dt &amp;lt;&amp;lt; New Column( "Relative " || (Column( c ) &amp;lt;&amp;lt; Get Name), Numeric, Continuous,
		Formula( :As Column( c ) /:Total )
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 05 Oct 2021 01:15:24 GMT</pubDate>
    <dc:creator>Rakendu</dc:creator>
    <dc:date>2021-10-05T01:15:24Z</dc:date>
    <item>
      <title>JMP 16: Script to add columns with formula, using relative reference</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-16-Script-to-add-columns-with-formula-using-relative/m-p/423067#M67217</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Trying to write my first ever script in JMP, would greatly appreciate some help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 10 columns (lets say one, two, three, four, five, six , seven, eight, nine, ten) and a Total column.&lt;/P&gt;&lt;P&gt;and i need to add ten more column which calculates the percentage of the first ten columns. I cannot use column names because i have 150 columns actually and the column names are all different.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do i get it to add a new column and everytime advance the column in the formula by 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example :&lt;/P&gt;&lt;P&gt;create new column col 11&lt;/P&gt;&lt;P&gt;fill with formula&amp;nbsp; "col 1 / Total"&lt;/P&gt;&lt;P&gt;set name of column to 'pct_one'&lt;/P&gt;&lt;P&gt;create new column col 12&lt;/P&gt;&lt;P&gt;fill with formula "col 2 / Total"&lt;/P&gt;&lt;P&gt;set name of column to 'pct_two'&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;continue for 10 columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:37:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-16-Script-to-add-columns-with-formula-using-relative/m-p/423067#M67217</guid>
      <dc:creator>Rakendu</dc:creator>
      <dc:date>2023-06-10T23:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: JMP 16: Script to add columns with formula, using relative reference</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-16-Script-to-add-columns-with-formula-using-relative/m-p/423486#M67252</link>
      <description>&lt;P&gt;See this example:&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 );

// mock up user data table
dt = New Table( "Mock Up" );
For( c = 1, c &amp;lt; 6, c++,
	col = dt &amp;lt;&amp;lt; New Column( "My Column " || Char( c ), Numeric, Continuous );
	col &amp;lt;&amp;lt; Set Values( J( 25, 1, Random Normal( 80, 5 ) ) );
);
y = dt &amp;lt;&amp;lt; Get As Matrix;
col = dt &amp;lt;&amp;lt; New Column( "Total", Numeric, Continuous );
col &amp;lt;&amp;lt; Set Values( y * J( 5, 1, 1 ) );

// solution
dt = Current Data Table();
total = Column( N Col( dt ) ) &amp;lt;&amp;lt; Get As Matrix;
last c = N Col( dt );
For( c = 1, c &amp;lt; last c,  c++,
	dt &amp;lt;&amp;lt; New Column( "Relative " || (Column( c ) &amp;lt;&amp;lt; Get Name), Numeric, Continuous,
		Values( (Column( c ) &amp;lt;&amp;lt; Get Values) :\&lt;/img&gt; total )
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Oct 2021 20:20:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-16-Script-to-add-columns-with-formula-using-relative/m-p/423486#M67252</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2021-10-04T20:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: JMP 16: Script to add columns with formula, using relative reference</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-16-Script-to-add-columns-with-formula-using-relative/m-p/423538#M67259</link>
      <description>&lt;P&gt;Thanks Mark! Worked like a charm!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did some tweaks, leaving it here for any future reference. Thanks alot!&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 );

// mock up user data table
dt = New Table( "Mock Up" );
For( c = 1, c &amp;lt; 6, c++,
	col = dt &amp;lt;&amp;lt; New Column( "My Column " || Char( c ), Numeric, Continuous );
	col &amp;lt;&amp;lt; Set Values( J( 25, 1, Random Normal( 80, 5 ) ) );
);
y = dt &amp;lt;&amp;lt; Get As Matrix;
col = dt &amp;lt;&amp;lt; New Column( "Total", Numeric, Continuous );
col &amp;lt;&amp;lt; Set Values( y * J( 5, 1, 1 ) );

// solution
dt = Current Data Table();
total = Column( N Col( dt ) ) &amp;lt;&amp;lt; Get As Matrix;
last c = N Col( dt );
For( c = 1, c &amp;lt; last c,  c++,
	dt &amp;lt;&amp;lt; New Column( "Relative " || (Column( c ) &amp;lt;&amp;lt; Get Name), Numeric, Continuous,
		Formula( :As Column( c ) /:Total )
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Oct 2021 01:15:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-16-Script-to-add-columns-with-formula-using-relative/m-p/423538#M67259</guid>
      <dc:creator>Rakendu</dc:creator>
      <dc:date>2021-10-05T01:15:24Z</dc:date>
    </item>
  </channel>
</rss>

