<?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 Func (IML) to return the row and col position of element in m x n matrix? in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Func-IML-to-return-the-row-and-col-position-of-element-in-m-x-n/m-p/23725#M105</link>
    <description>I want to know if there is any SAS/IML function which returns the row and column location of an element with a M x N or N x N Matrix. &lt;BR /&gt;
&lt;BR /&gt;
For example, I want to know the location of the smallest element in the matrix A. I can find the element using &lt;BR /&gt;
&lt;BR /&gt;
&amp;gt;&amp;gt;a=loc(min(A));&lt;BR /&gt;
&lt;BR /&gt;
This returns the elements value, but not the position within the matrix.&lt;BR /&gt;
&lt;BR /&gt;
Even when I try&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt;&amp;gt;b=ncol(min(A)); &lt;BR /&gt;
&amp;gt;&amp;gt;c=nrow(min(A));&lt;BR /&gt;
&lt;BR /&gt;
SAS/IML only return column=1 row=1, since it still recognizes the elements as a value, separate from the Matrix.&lt;BR /&gt;
&lt;BR /&gt;
Appreciate any help you could give.</description>
    <pubDate>Tue, 18 May 2010 13:42:29 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-05-18T13:42:29Z</dc:date>
    <item>
      <title>Func (IML) to return the row and col position of element in m x n matrix?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Func-IML-to-return-the-row-and-col-position-of-element-in-m-x-n/m-p/23725#M105</link>
      <description>I want to know if there is any SAS/IML function which returns the row and column location of an element with a M x N or N x N Matrix. &lt;BR /&gt;
&lt;BR /&gt;
For example, I want to know the location of the smallest element in the matrix A. I can find the element using &lt;BR /&gt;
&lt;BR /&gt;
&amp;gt;&amp;gt;a=loc(min(A));&lt;BR /&gt;
&lt;BR /&gt;
This returns the elements value, but not the position within the matrix.&lt;BR /&gt;
&lt;BR /&gt;
Even when I try&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt;&amp;gt;b=ncol(min(A)); &lt;BR /&gt;
&amp;gt;&amp;gt;c=nrow(min(A));&lt;BR /&gt;
&lt;BR /&gt;
SAS/IML only return column=1 row=1, since it still recognizes the elements as a value, separate from the Matrix.&lt;BR /&gt;
&lt;BR /&gt;
Appreciate any help you could give.</description>
      <pubDate>Tue, 18 May 2010 13:42:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Func-IML-to-return-the-row-and-col-position-of-element-in-m-x-n/m-p/23725#M105</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-05-18T13:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: Func (IML) to return the row and col position of element in m x n matrix?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Func-IML-to-return-the-row-and-col-position-of-element-in-m-x-n/m-p/23726#M106</link>
      <description>Put the condition that you are searching for inside the LOC statement, as in &lt;BR /&gt;
   idx = loc( A = min(A) ); /* indices where A equals min(A) */&lt;BR /&gt;
or, in general,&lt;BR /&gt;
   idx = loc( A = value ); /* indices where A equals 'value' */&lt;BR /&gt;
&lt;BR /&gt;
The previous statements return ALL indices that satisfy the condition.&lt;BR /&gt;
It turns out that for "index of minimum" and "index of maximum" there is a subscript reduction operator that returns the FIRST index that satisfies the condition. See&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/imlug/59656/HTML/default/workmatrix_sect14.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/imlug/59656/HTML/default/workmatrix_sect14.htm&lt;/A&gt;</description>
      <pubDate>Tue, 18 May 2010 15:43:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Func-IML-to-return-the-row-and-col-position-of-element-in-m-x-n/m-p/23726#M106</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2010-05-18T15:43:40Z</dc:date>
    </item>
  </channel>
</rss>

