<?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: ERROR: Array subscript out of range at line in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/ERROR-Array-subscript-out-of-range-at-line/m-p/478932#M71428</link>
    <description>&lt;P&gt;Arrays in SAS are 1 based, so the first element is accessed like arrayName{1}, so in your loop you try to get an array element as arrayName{1-1} which makes it 0, so this is way you get the error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Jul 2018 07:07:14 GMT</pubDate>
    <dc:creator>BrunoMueller</dc:creator>
    <dc:date>2018-07-18T07:07:14Z</dc:date>
    <item>
      <title>ERROR: Array subscript out of range at line</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ERROR-Array-subscript-out-of-range-at-line/m-p/478927#M71427</link>
      <description>&lt;P&gt;I'm trying my hand at incorporating time-dependent variables in cox proportional hazard modeling through the counting process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am up to the first step - creating indicator variables to tell me when the "nlr" status changes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA change;&lt;BR /&gt;SET change;&lt;BR /&gt;ARRAY nlr_(*) nlr_0-nlr_3; *call in the time-varying nlr variables;&lt;BR /&gt;ARRAY chng(3); *the new indicator variables;&lt;BR /&gt;t=1; *initialise the position variable for the indicator variables;&lt;BR /&gt;DO i = 1 to 3;&lt;BR /&gt;if nlr_(i) NE nlr_(i-1) THEN DO; *detects whether there is a change in nlr status;&lt;BR /&gt;chng(t) = i-1; *assigns the last timept the status remained constant;&lt;BR /&gt;t=t+1;&lt;BR /&gt;END;&lt;BR /&gt;END;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;However, this message is popping up in my log -&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ERROR: Array subscript out of range at line 2863 column 20.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is from the change dataset:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;subjid3&lt;/TD&gt;&lt;TD&gt;nlr_0&lt;/TD&gt;&lt;TD&gt;nlr_1&lt;/TD&gt;&lt;TD&gt;nlr_2&lt;/TD&gt;&lt;TD&gt;nlr_3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A10&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A100&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I am aiming for it to look like this:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;subjid3&lt;/TD&gt;&lt;TD&gt;chng1&lt;/TD&gt;&lt;TD&gt;chng2&lt;/TD&gt;&lt;TD&gt;chng3&lt;/TD&gt;&lt;TD&gt;nlr_0&lt;/TD&gt;&lt;TD&gt;nlr_1&lt;/TD&gt;&lt;TD&gt;nlr_2&lt;/TD&gt;&lt;TD&gt;nlr_3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A1&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A10&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A100&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure what I am doing wrong - appreciate any input (sorry am a beginner at this!)&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 05:53:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ERROR-Array-subscript-out-of-range-at-line/m-p/478927#M71427</guid>
      <dc:creator>lavienrose1</dc:creator>
      <dc:date>2018-07-18T05:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Array subscript out of range at line</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ERROR-Array-subscript-out-of-range-at-line/m-p/478932#M71428</link>
      <description>&lt;P&gt;Arrays in SAS are 1 based, so the first element is accessed like arrayName{1}, so in your loop you try to get an array element as arrayName{1-1} which makes it 0, so this is way you get the error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 07:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ERROR-Array-subscript-out-of-range-at-line/m-p/478932#M71428</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2018-07-18T07:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Array subscript out of range at line</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ERROR-Array-subscript-out-of-range-at-line/m-p/478951#M71430</link>
      <description>&lt;P&gt;Since you iterate over 3 values, but also use i-1 to access an array element, you in fact try to access &lt;EM&gt;four&lt;/EM&gt; array elements in arrays that only have &lt;EM&gt;three&lt;/EM&gt; elements.&lt;/P&gt;
&lt;P&gt;Your code needs to take care of the border cases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whenever an out-of-range error like this happens, you also get a list of all current variable values. Inspect that, and you'll see what happens.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 08:07:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ERROR-Array-subscript-out-of-range-at-line/m-p/478951#M71430</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-18T08:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Array subscript out of range at line</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ERROR-Array-subscript-out-of-range-at-line/m-p/479011#M71432</link>
      <description>&lt;P&gt;The simplest change I would recommend is to change one of the array definitions.&amp;nbsp; What you have now:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ARRAY nlr_(*) nlr_0-nlr_3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What it should look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ARRAY nlr_ (0:3) nlr_0-nlr_3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But for the life of me I can't figure out how you are getting values for the CHNG variables and why you want the values that you illustrate.&amp;nbsp; So that question will arise once you get past the errors.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 12:50:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ERROR-Array-subscript-out-of-range-at-line/m-p/479011#M71432</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-07-18T12:50:14Z</dc:date>
    </item>
  </channel>
</rss>

