<?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 do I perform row operations in looping? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-perform-row-operations-in-looping/m-p/53834#M30413</link>
    <description>&lt;P&gt;Here are a couple of ways to do the looping........more ways exist, but I will let others show them&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Open the data table
dt1 = Open( "$SAMPLE_DATA\Blood Pressure.jmp" );

// Create a second copy
dt2 = dt1 &amp;lt;&amp;lt; subset( selected columns( 0 ), selected rows( 0 ) );

// Get all numeric, continuous column names 
colList = dt1 &amp;lt;&amp;lt; get column names( string, numeric, continuous );

// Loop across all numeric, continuous columns and use a 
// matrix operation to handle the math
For( i = 1, i &amp;lt;= N Items( colList ), i++,
	mat = Column( dt1, colList[i] ) &amp;lt;&amp;lt; get values;
	mat = mat - mat[1];
	Column( dt1, colList[i] ) &amp;lt;&amp;lt; set values( mat );
);


// Now do the same thing looping with the data in place
// Loop across all numeric, continuous columns
For( i = 1, i &amp;lt;= N Items( colList ), i++, 

	// Go through each row, from the bottom to the top to subtract
	// the value of the first row from each rows value
	For( k = N Rows( dt2 ), k &amp;gt;= 1, k--,
		Column( dt2, colList[i] )[k] = Column( dt2, colList[i] )[k] - Column( dt2, colList[i] )[1]
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 26 Mar 2018 12:38:44 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2018-03-26T12:38:44Z</dc:date>
    <item>
      <title>How do I perform row operations in looping?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-perform-row-operations-in-looping/m-p/53833#M30412</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a table like below.&lt;/P&gt;&lt;P&gt;A B C ..n columns&lt;/P&gt;&lt;P&gt;1 2 3&lt;/P&gt;&lt;P&gt;7 6 4&lt;/P&gt;&lt;P&gt;3 7 9&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;m rows&lt;/P&gt;&lt;P&gt;I want to write a script such that for every column " Value of nth row= Value of nth row -Value of 1st row" and in the end reset the first row to 0. So in the end my table should look like&lt;/P&gt;&lt;P&gt;A B C&lt;/P&gt;&lt;P&gt;0 0 0..&lt;/P&gt;&lt;P&gt;6 4 1&lt;/P&gt;&lt;P&gt;2 5 6&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;Could someone help me with a script for such an operation? Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Mar 2018 11:35:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-perform-row-operations-in-looping/m-p/53833#M30412</guid>
      <dc:creator>PG</dc:creator>
      <dc:date>2018-03-26T11:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I perform row operations in looping?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-perform-row-operations-in-looping/m-p/53834#M30413</link>
      <description>&lt;P&gt;Here are a couple of ways to do the looping........more ways exist, but I will let others show them&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Open the data table
dt1 = Open( "$SAMPLE_DATA\Blood Pressure.jmp" );

// Create a second copy
dt2 = dt1 &amp;lt;&amp;lt; subset( selected columns( 0 ), selected rows( 0 ) );

// Get all numeric, continuous column names 
colList = dt1 &amp;lt;&amp;lt; get column names( string, numeric, continuous );

// Loop across all numeric, continuous columns and use a 
// matrix operation to handle the math
For( i = 1, i &amp;lt;= N Items( colList ), i++,
	mat = Column( dt1, colList[i] ) &amp;lt;&amp;lt; get values;
	mat = mat - mat[1];
	Column( dt1, colList[i] ) &amp;lt;&amp;lt; set values( mat );
);


// Now do the same thing looping with the data in place
// Loop across all numeric, continuous columns
For( i = 1, i &amp;lt;= N Items( colList ), i++, 

	// Go through each row, from the bottom to the top to subtract
	// the value of the first row from each rows value
	For( k = N Rows( dt2 ), k &amp;gt;= 1, k--,
		Column( dt2, colList[i] )[k] = Column( dt2, colList[i] )[k] - Column( dt2, colList[i] )[1]
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Mar 2018 12:38:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-perform-row-operations-in-looping/m-p/53834#M30413</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-03-26T12:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do I perform row operations in looping?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-perform-row-operations-in-looping/m-p/53901#M30448</link>
      <description>Thanks txnelson. It works perfectly.</description>
      <pubDate>Tue, 27 Mar 2018 07:27:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-perform-row-operations-in-looping/m-p/53901#M30448</guid>
      <dc:creator>PG</dc:creator>
      <dc:date>2018-03-27T07:27:51Z</dc:date>
    </item>
  </channel>
</rss>

