<?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 Sort, if statement in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Sort-if-statement/m-p/730206#M5440</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have m failure observations X_1,X_2,...,X_m. The study ends at time (T) I may observe the mth failure before time T and I may not. If the mth failure is observed after time T then I have to know its value. However, I don't know how to write that part and I really appreciate any help.&lt;/P&gt;&lt;P&gt;AT the same time I need to know the failure value that took place just before T and its position, i.e.&amp;nbsp; &amp;nbsp;the j value such that X_(j) &amp;lt; T &amp;lt; X_(j+1). For this I wrote the code below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;call sortndx(idx, x, 1);&lt;/P&gt;&lt;P&gt;do idx=1 to m;&lt;/P&gt;&lt;P&gt;if (( X[idx] &amp;lt; T) &amp;amp; (X[idx+1] &amp;gt; T)) then j=idx;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;print&amp;nbsp; j;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, I keep on getting the following error message&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="Salah_0-1617137502658.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56680i03CDAD041426119A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Salah_0-1617137502658.png" alt="Salah_0-1617137502658.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Mar 2021 21:00:23 GMT</pubDate>
    <dc:creator>Salah</dc:creator>
    <dc:date>2021-03-30T21:00:23Z</dc:date>
    <item>
      <title>Sort, if statement</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Sort-if-statement/m-p/730206#M5440</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have m failure observations X_1,X_2,...,X_m. The study ends at time (T) I may observe the mth failure before time T and I may not. If the mth failure is observed after time T then I have to know its value. However, I don't know how to write that part and I really appreciate any help.&lt;/P&gt;&lt;P&gt;AT the same time I need to know the failure value that took place just before T and its position, i.e.&amp;nbsp; &amp;nbsp;the j value such that X_(j) &amp;lt; T &amp;lt; X_(j+1). For this I wrote the code below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;call sortndx(idx, x, 1);&lt;/P&gt;&lt;P&gt;do idx=1 to m;&lt;/P&gt;&lt;P&gt;if (( X[idx] &amp;lt; T) &amp;amp; (X[idx+1] &amp;gt; T)) then j=idx;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;print&amp;nbsp; j;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, I keep on getting the following error message&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="Salah_0-1617137502658.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56680i03CDAD041426119A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Salah_0-1617137502658.png" alt="Salah_0-1617137502658.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 21:00:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Sort-if-statement/m-p/730206#M5440</guid>
      <dc:creator>Salah</dc:creator>
      <dc:date>2021-03-30T21:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: Sort, if statement</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Sort-if-statement/m-p/730213#M5441</link>
      <description>&lt;P&gt;The error message tells you that you are trying to access X[6] even though X only has 5 elements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The problem occurs because the second part of your IF/THEN statement has the expression &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;X[idx+1] &amp;gt; T&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;and idx+1=6 when the loop index has the value idx=5.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I'm not sure what you are trying to accomplish with the loop, but if you want to find all elements of X that are less than T, you can use&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;k = loc(X&amp;lt;T);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if k is empty, then no failures occurred before T. If k is not empty, then X[k[ncol(k)]] is the value of the greatest time less than T.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 21:45:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Sort-if-statement/m-p/730213#M5441</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-03-30T21:45:25Z</dc:date>
    </item>
  </channel>
</rss>

