<?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 Reading the first in every set of values in a column in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Reading-the-first-in-every-set-of-values-in-a-column/m-p/237879#M2502</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a matrix (let's call it D) with 20 rows (+ column name) and 2 columns. The matrix has been sorted in a particular way, and I want to read the first of every 4 values in the the first column to another matrix. The following code worked on a small "test" dataset (small enough that I could check the results manually), but is there a reason it could produce wrong results (for example, read a number twice from a particular set of four, but zero times from another set)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;proc iml;&lt;/DIV&gt;
&lt;DIV&gt;use sasdata.testnum;&lt;/DIV&gt;
&lt;DIV&gt;read all var _ALL_ into D[colname = varNames];&lt;/DIV&gt;
&lt;DIV&gt;close sasdata.testnum;&lt;/DIV&gt;
&lt;DIV&gt;print D;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;T = j(5, 1, 0);&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;t_row = 1;&lt;/DIV&gt;
&lt;DIV&gt;do y = 1 to 21 by 4;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; T[t_row, 1] = D[y, 1];&lt;/DIV&gt;
&lt;DIV&gt;t_row = t_row + 1;&lt;/DIV&gt;
&lt;DIV&gt;print T;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;end;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;In other words, does anyone see anything wrong with this code? Is there a better way of doing what I have done here?&lt;/P&gt;</description>
    <pubDate>Fri, 04 Dec 2015 19:09:14 GMT</pubDate>
    <dc:creator>dvtarasov</dc:creator>
    <dc:date>2015-12-04T19:09:14Z</dc:date>
    <item>
      <title>Reading the first in every set of values in a column</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Reading-the-first-in-every-set-of-values-in-a-column/m-p/237879#M2502</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a matrix (let's call it D) with 20 rows (+ column name) and 2 columns. The matrix has been sorted in a particular way, and I want to read the first of every 4 values in the the first column to another matrix. The following code worked on a small "test" dataset (small enough that I could check the results manually), but is there a reason it could produce wrong results (for example, read a number twice from a particular set of four, but zero times from another set)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;proc iml;&lt;/DIV&gt;
&lt;DIV&gt;use sasdata.testnum;&lt;/DIV&gt;
&lt;DIV&gt;read all var _ALL_ into D[colname = varNames];&lt;/DIV&gt;
&lt;DIV&gt;close sasdata.testnum;&lt;/DIV&gt;
&lt;DIV&gt;print D;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;T = j(5, 1, 0);&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;t_row = 1;&lt;/DIV&gt;
&lt;DIV&gt;do y = 1 to 21 by 4;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; T[t_row, 1] = D[y, 1];&lt;/DIV&gt;
&lt;DIV&gt;t_row = t_row + 1;&lt;/DIV&gt;
&lt;DIV&gt;print T;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;end;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;In other words, does anyone see anything wrong with this code? Is there a better way of doing what I have done here?&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2015 19:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Reading-the-first-in-every-set-of-values-in-a-column/m-p/237879#M2502</guid>
      <dc:creator>dvtarasov</dc:creator>
      <dc:date>2015-12-04T19:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: Reading the first in every set of values in a column</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Reading-the-first-in-every-set-of-values-in-a-column/m-p/237880#M2503</link>
      <description>&lt;P&gt;Have you considered using the var _n_ along with a divisibility function I believe it is called MODZ () ??&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2015 19:19:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Reading-the-first-in-every-set-of-values-in-a-column/m-p/237880#M2503</guid>
      <dc:creator>kannand</dc:creator>
      <dc:date>2015-12-04T19:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: Reading the first in every set of values in a column</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Reading-the-first-in-every-set-of-values-in-a-column/m-p/237884#M2504</link>
      <description>&lt;P&gt;Use this. It uses the DO function to generate the sequewnce {1, 5, 9,...}:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;t_row = do(1, nrow(D), 4);
T = D[t_row, 1];&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Dec 2015 19:38:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Reading-the-first-in-every-set-of-values-in-a-column/m-p/237884#M2504</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-12-04T19:38:11Z</dc:date>
    </item>
  </channel>
</rss>

