<?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 use the formula row by row to find the dynamic change of the total number of columns. in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-use-the-formula-row-by-row-to-find-the-dynamic-change-of/m-p/246676#M48432</link>
    <description>&lt;P&gt;This situation is weird. This script builds the formula:&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 = Open( "$SAMPLE_DATA/Diabetes.jmp" );

col = dt &amp;lt;&amp;lt; New Column( "test" );

lo = 6;
hi = 9;
f = Expr( Add() );

For( c = lo, c &amp;lt;= hi, c++,
	r = (dt &amp;lt;&amp;lt; Get Column Reference( Eval List( { Column( dt, c ) &amp;lt;&amp;lt; Get Name } ) ))[1];
	Insert Into( f, r );
);

Eval(
	Substitute(
		Expr( col &amp;lt;&amp;lt; Set Formula( fff ) ),
		Expr( fff ),
		Name Expr( f )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But it does not evaluate. Yet it works if I examine the preview in the formula editor.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 857px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/21680iE1F6D538EDC5D7A7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, why use a formula when you don't want to?&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 = Open( "$SAMPLE_DATA/Diabetes.jmp" );

col = dt &amp;lt;&amp;lt; New Column( "test" );

lo = 6;
hi = 9;
sum = J( N Row( dt ), 1, 0 );

For( c = lo, c &amp;lt;= hi, c++,
	sum += Column( dt, c ) &amp;lt;&amp;lt; Get As Matrix;
);

col &amp;lt;&amp;lt; Set Values( sum );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 10 Feb 2020 11:14:56 GMT</pubDate>
    <dc:creator>Mark_Bailey</dc:creator>
    <dc:date>2020-02-10T11:14:56Z</dc:date>
    <item>
      <title>How to use the formula row by row to find the dynamic change of the total number of columns.</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-the-formula-row-by-row-to-find-the-dynamic-change-of/m-p/246663#M48428</link>
      <description>&lt;P&gt;How to use the formula row by row to find the dynamic change of the total number of columns.&lt;BR /&gt;Such as setting:&lt;BR /&gt;The number a is the number of starting column positions that need to be summed&lt;BR /&gt;The number b is the total number of columns that need to be summed&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA/Diabetes.jmp" );
dt &amp;lt;&amp;lt; New Column( "test", formula( As Column( 6 ) + As Column( 7 ) + As Column( 8 ) + As Column( 9 ) ) );
dt &amp;lt;&amp;lt; run formulas;
Column( "test" ) &amp;lt;&amp;lt; deleteFormula;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Such as:&lt;BR /&gt;A = 6;&lt;BR /&gt;B = 4;&lt;BR /&gt;Find the sum of columns 6, 7, 8, and 9 in the new "text" column (starting with column a, total column b).&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020-02-10_17-00.png" style="width: 724px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/21679i0C9AB3DDEEE1E392/image-size/large?v=v2&amp;amp;px=999" role="button" title="2020-02-10_17-00.png" alt="2020-02-10_17-00.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 09:02:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-the-formula-row-by-row-to-find-the-dynamic-change-of/m-p/246663#M48428</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2020-02-10T09:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the formula row by row to find the dynamic change of the total number of columns.</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-the-formula-row-by-row-to-find-the-dynamic-change-of/m-p/246670#M48429</link>
      <description>&lt;UL&gt;&lt;LI&gt;&lt;P class="src"&gt;I tried to write it this way, but it didn't work.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;a=6;b=4;
dt = Current Data Table();
dt&amp;lt;&amp;lt;New Column("text",formula(
g=0;
for(i=6,i&amp;lt;=a+b-1,i++,
g=g+As Column(i+1)	
)));dt&amp;lt;&amp;lt;run formulas;
Column("text")&amp;lt;&amp;lt;deleteFormula;Wait(0);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Looks like it's going to be in the brute force form of a line by line loop, right?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 09:08:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-the-formula-row-by-row-to-find-the-dynamic-change-of/m-p/246670#M48429</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2020-02-10T09:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the formula row by row to find the dynamic change of the total number of columns.</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-the-formula-row-by-row-to-find-the-dynamic-change-of/m-p/246676#M48432</link>
      <description>&lt;P&gt;This situation is weird. This script builds the formula:&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 = Open( "$SAMPLE_DATA/Diabetes.jmp" );

col = dt &amp;lt;&amp;lt; New Column( "test" );

lo = 6;
hi = 9;
f = Expr( Add() );

For( c = lo, c &amp;lt;= hi, c++,
	r = (dt &amp;lt;&amp;lt; Get Column Reference( Eval List( { Column( dt, c ) &amp;lt;&amp;lt; Get Name } ) ))[1];
	Insert Into( f, r );
);

Eval(
	Substitute(
		Expr( col &amp;lt;&amp;lt; Set Formula( fff ) ),
		Expr( fff ),
		Name Expr( f )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But it does not evaluate. Yet it works if I examine the preview in the formula editor.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 857px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/21680iE1F6D538EDC5D7A7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, why use a formula when you don't want to?&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 = Open( "$SAMPLE_DATA/Diabetes.jmp" );

col = dt &amp;lt;&amp;lt; New Column( "test" );

lo = 6;
hi = 9;
sum = J( N Row( dt ), 1, 0 );

For( c = lo, c &amp;lt;= hi, c++,
	sum += Column( dt, c ) &amp;lt;&amp;lt; Get As Matrix;
);

col &amp;lt;&amp;lt; Set Values( sum );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Feb 2020 11:14:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-the-formula-row-by-row-to-find-the-dynamic-change-of/m-p/246676#M48432</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2020-02-10T11:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the formula row by row to find the dynamic change of the total number of columns.</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-the-formula-row-by-row-to-find-the-dynamic-change-of/m-p/246678#M48433</link>
      <description>&lt;P&gt;Thank markbailey!&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.jmp.com/t5/Discussions/How-to-SUM-rows-with-variable-column-names/m-p/9817" target="_self"&gt;https://community.jmp.com/t5/Discussions/How-to-SUM-rows-with-variable-column-names/m-p/9817&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Seeing this post, I also tried this method, but to determine the number of text format columns.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA/Diabetes.jmp" );
a = 4;//has 2 text format columns.
b = 4;
m = (dt &amp;lt;&amp;lt; get as matrix)[0, Index( a, a + b - 1 )];
s = (V Sum( m` ))`;
dt &amp;lt;&amp;lt; New Column( "test", Numeric, Continuous, Values( s ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Feb 2020 11:40:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-the-formula-row-by-row-to-find-the-dynamic-change-of/m-p/246678#M48433</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2020-02-10T11:40:30Z</dc:date>
    </item>
  </channel>
</rss>

