<?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: Array Error :Array subscript out of range in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Array-Error-Array-subscript-out-of-range/m-p/944592#M370089</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436607"&gt;@Discaboota&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error message referring to "column 128" indicates that the array reference in the second IF-THEN statement is the culprit because that is the position of the first "&lt;FONT face="courier new,courier"&gt;Q&lt;/FONT&gt;" in "&lt;FONT face="courier new,courier"&gt;Q[WHICHN(31,OF Q[*])]&lt;/FONT&gt;". And this is indeed the odd one among the three similar statements: The IF condition&lt;/P&gt;
&lt;PRE&gt;((61 IN Q AND 32 IN Q) &lt;FONT size="3" color="#800080"&gt;&lt;STRONG&gt;OR&lt;/STRONG&gt;&lt;/FONT&gt; (31 IN Q)) AND 1 NOT IN Q AND BILLING_CYCLE_DAY = 15&lt;/PRE&gt;
&lt;P&gt;does &lt;EM&gt;not&lt;/EM&gt; imply &lt;FONT face="courier new,courier"&gt;31 in Q&lt;/FONT&gt;. But if &lt;FONT face="courier new,courier"&gt;31&lt;/FONT&gt; is &lt;FONT face="courier new,courier"&gt;not in Q&lt;/FONT&gt;, the above mentioned call to the WHICHN function returns &lt;FONT face="courier new,courier"&gt;0&lt;/FONT&gt; and the resulting array reference &lt;FONT face="courier new,courier"&gt;Q[0]&lt;/FONT&gt; causes the error message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you'll need to add programming logic for the case&lt;/P&gt;
&lt;PRE&gt;((61 IN Q AND 32 IN Q) &lt;FONT size="3" color="#800080"&gt;&lt;STRONG&gt;AND NOT&lt;/STRONG&gt;&lt;/FONT&gt; (31 IN Q)) AND 1 NOT IN Q AND BILLING_CYCLE_DAY = 15&lt;/PRE&gt;</description>
    <pubDate>Thu, 19 Sep 2024 13:40:06 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2024-09-19T13:40:06Z</dc:date>
    <item>
      <title>Array Error :Array subscript out of range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Error-Array-subscript-out-of-range/m-p/944588#M370086</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA CYCLE15_ALLOCATION_&amp;amp;PREVMNTH._&amp;amp;MNTH.2(WHERE=(ALLOCATION_DATE NE .) KEEP=ACCOUNT_NO BILLING_CYCLE_DAY ALLOCATION_DATE TAGGING OPENING_DPD);
SET MASTER_DPD_DUELIST_&amp;amp;PREVMNTH._&amp;amp;MNTH.(WHERE=(BKT NOT IN ('WOFF','NPA','NPA_A')) KEEP= ACCOUNT_NO BILLING_CYCLE_DAY BKT
dpd_01SEP24 -- DPD_18SEP24);
FORMAT ALLOCATION_DATE DATE7. TAGGING $CHAR25.;
ARRAY Q[*] _NUMERIC_;
IF 61 IN Q AND 31 NOT IN Q AND 1 NOT IN Q AND BILLING_CYCLE_DAY = 15 THEN DO;ALLOCATION_DATE = INPUT(SUBSTR(VNAME(Q[WHICHN(61,OF Q[*])]),5),DATE7.);OPENING_DPD = 61;TAGGING = 'BUCKET 2 NON NPA';END;
IF ((61 IN Q AND 32 IN Q) OR (31 IN Q)) AND 1 NOT IN Q AND BILLING_CYCLE_DAY = 15 THEN DO;ALLOCATION_DATE = INPUT(SUBSTR(VNAME(Q[WHICHN(31,OF Q[*])]),5),DATE7.);OPENING_DPD = 31;TAGGING = 'BUCKET 1 NON NPA';END;
IF 1 IN Q AND 61 NOT IN Q AND 31 NOT IN Q  AND BILLING_CYCLE_DAY = 15 THEN DO;ALLOCATION_DATE = INPUT(SUBSTR(VNAME(Q[WHICHN(1,OF Q[*])]),5),DATE7.);OPENING_DPD = 1;TAGGING = 'BUCKET X NON NPA';END;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I tried to create an array, When I tried to execute it,&lt;/P&gt;
&lt;P&gt;there was an error:&amp;nbsp;&lt;/P&gt;
&lt;DIV id="sasLogError1_1726750168572" class="sasError"&gt;ERROR: Array subscript out of range at line 101 column 128.&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;I want to put the conditions in array Q, how can I resolve this issue?&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 13:03:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Error-Array-subscript-out-of-range/m-p/944588#M370086</guid>
      <dc:creator>Discaboota</dc:creator>
      <dc:date>2024-09-19T13:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: Array Error :Array subscript out of range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Error-Array-subscript-out-of-range/m-p/944589#M370087</link>
      <description>&lt;P&gt;When you get errors, we need to see the log. We need to see the entire log for this DATA step, including the code as it appears in the log, and any ERROR/WARNING/NOTEs that appear for this DATA step, not selected parts of the log for this DATA step. Please use the &amp;lt;/&amp;gt; icon, copy the log as text and paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaigeMiller_0-1663012019648.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75161i0E71B1489A6C9839/image-size/large?v=v2&amp;amp;px=999" role="button" title="PaigeMiller_0-1663012019648.png" alt="PaigeMiller_0-1663012019648.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 13:09:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Error-Array-subscript-out-of-range/m-p/944589#M370087</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-09-19T13:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: Array Error :Array subscript out of range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Error-Array-subscript-out-of-range/m-p/944592#M370089</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436607"&gt;@Discaboota&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error message referring to "column 128" indicates that the array reference in the second IF-THEN statement is the culprit because that is the position of the first "&lt;FONT face="courier new,courier"&gt;Q&lt;/FONT&gt;" in "&lt;FONT face="courier new,courier"&gt;Q[WHICHN(31,OF Q[*])]&lt;/FONT&gt;". And this is indeed the odd one among the three similar statements: The IF condition&lt;/P&gt;
&lt;PRE&gt;((61 IN Q AND 32 IN Q) &lt;FONT size="3" color="#800080"&gt;&lt;STRONG&gt;OR&lt;/STRONG&gt;&lt;/FONT&gt; (31 IN Q)) AND 1 NOT IN Q AND BILLING_CYCLE_DAY = 15&lt;/PRE&gt;
&lt;P&gt;does &lt;EM&gt;not&lt;/EM&gt; imply &lt;FONT face="courier new,courier"&gt;31 in Q&lt;/FONT&gt;. But if &lt;FONT face="courier new,courier"&gt;31&lt;/FONT&gt; is &lt;FONT face="courier new,courier"&gt;not in Q&lt;/FONT&gt;, the above mentioned call to the WHICHN function returns &lt;FONT face="courier new,courier"&gt;0&lt;/FONT&gt; and the resulting array reference &lt;FONT face="courier new,courier"&gt;Q[0]&lt;/FONT&gt; causes the error message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you'll need to add programming logic for the case&lt;/P&gt;
&lt;PRE&gt;((61 IN Q AND 32 IN Q) &lt;FONT size="3" color="#800080"&gt;&lt;STRONG&gt;AND NOT&lt;/STRONG&gt;&lt;/FONT&gt; (31 IN Q)) AND 1 NOT IN Q AND BILLING_CYCLE_DAY = 15&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Sep 2024 13:40:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Error-Array-subscript-out-of-range/m-p/944592#M370089</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-09-19T13:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Array Error :Array subscript out of range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Error-Array-subscript-out-of-range/m-p/944593#M370090</link>
      <description>&lt;P&gt;If you are able to in the future, do you mind formatting the code? It would certainly help debugging. I went ahead and did it just to see.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA CYCLE15_ALLOCATION_&amp;amp;PREVMNTH._&amp;amp;MNTH.2 (
    WHERE=(ALLOCATION_DATE NE .) 
    KEEP=ACCOUNT_NO BILLING_CYCLE_DAY ALLOCATION_DATE TAGGING OPENING_DPD
  );
  SET MASTER_DPD_DUELIST_&amp;amp;PREVMNTH._&amp;amp;MNTH. (
      WHERE=(BKT NOT IN ('WOFF','NPA','NPA_A'))
      KEEP= ACCOUNT_NO BILLING_CYCLE_DAY BKT dpd_01SEP24 -- DPD_18SEP24
  );
FORMAT ALLOCATION_DATE DATE7. TAGGING $CHAR25.;
ARRAY Q[*] _NUMERIC_;
IF 61 IN Q AND 31 NOT IN Q AND 1 NOT IN Q AND BILLING_CYCLE_DAY = 15 THEN DO;
  ALLOCATION_DATE = INPUT(SUBSTR(VNAME(Q[WHICHN(61,OF Q[*])]),5),DATE7.);
  OPENING_DPD = 61;
  TAGGING = 'BUCKET 2 NON NPA';
END;
IF ((61 IN Q AND 32 IN Q) OR (31 IN Q)) AND 1 NOT IN Q AND BILLING_CYCLE_DAY = 15 THEN DO;
  ALLOCATION_DATE = INPUT(SUBSTR(VNAME(Q[WHICHN(31,OF Q[*])]),5),DATE7.);
  OPENING_DPD = 31;
  TAGGING = 'BUCKET 1 NON NPA';
END;
IF 1 IN Q AND 61 NOT IN Q AND 31 NOT IN Q  AND BILLING_CYCLE_DAY = 15 THEN DO;
  ALLOCATION_DATE = INPUT(SUBSTR(VNAME(Q[WHICHN(1,OF Q[*])]),5),DATE7.);
  OPENING_DPD = 1;
  TAGGING = 'BUCKET X NON NPA';
END;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Sep 2024 13:43:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Error-Array-subscript-out-of-range/m-p/944593#M370090</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2024-09-19T13:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: Array Error :Array subscript out of range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-Error-Array-subscript-out-of-range/m-p/944594#M370091</link>
      <description>&lt;P&gt;Awful ugly code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am going to go out on a limb and after reformatting part of that code to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;IF 61 IN Q AND 31 NOT IN Q AND 1 NOT IN Q AND BILLING_CYCLE_DAY = 15 THEN DO;
   ALLOCATION_DATE = INPUT(SUBSTR(VNAME(Q[WHICHN(61,OF Q[*])]),5),DATE7.);
   OPENING_DPD = 61;
   TAGGING = 'BUCKET 2 NON NPA';
END;
IF ((61 IN Q AND 32 IN Q) OR (31 IN Q)) AND 1 NOT IN Q AND BILLING_CYCLE_DAY = 15 THEN DO;
&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;   ALLOCATION_DATE = INPUT(SUBSTR(VNAME(Q[WHICHN(31,OF Q[*])]),5),DATE7.);&lt;/STRONG&gt;&lt;/FONT&gt;
   OPENING_DPD = 31;
   TAGGING = 'BUCKET 1 NON NPA';
END;
IF 1 IN Q AND 61 NOT IN Q AND 31 NOT IN Q  AND BILLING_CYCLE_DAY = 15 THEN DO;
   ALLOCATION_DATE = INPUT(SUBSTR(VNAME(Q[WHICHN(1,OF Q[*])]),5),DATE7.);
   OPENING_DPD = 1;
   TAGGING = 'BUCKET X NON NPA';
END;&lt;/PRE&gt;
&lt;P&gt;guess that this is the line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;   ALLOCATION_DATE = INPUT(SUBSTR(VNAME(Q[WHICHN(31,OF Q[*])]),5),DATE7.);&lt;/PRE&gt;
&lt;P&gt;The conditions that get to this line start with&lt;/P&gt;
&lt;PRE&gt;((61 IN Q AND 32 IN Q) OR (31 IN Q)) &lt;/PRE&gt;
&lt;P&gt;Which means 61 and 32 may be there but there is no requirement for 31 to be there. So for some observation with that true then Whichn(31,of q(*)) is returning 0, which would be the specific subscript that is out of range.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One really hopes your code doesn't look at posted in the question or you will be wasting lots of time trying to decipher "line number" in general because you have places several statements on one line making the diagnostics much less useful.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 13:55:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-Error-Array-subscript-out-of-range/m-p/944594#M370091</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-09-19T13:55:31Z</dc:date>
    </item>
  </channel>
</rss>

