<?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 subscript out of range in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/ARRAY-subscript-out-of-range/m-p/570718#M75254</link>
    <description>&lt;P&gt;No miracle. The maximum size of any array is 8, while you try to iterate i up to 75.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Jul 2019 19:14:24 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-07-02T19:14:24Z</dc:date>
    <item>
      <title>ARRAY subscript out of range</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ARRAY-subscript-out-of-range/m-p/570712#M75253</link>
      <description>&lt;P&gt;i have a dataset of dummy variables (0,1, .) that I want to use to determine the value of a new variable, "source". I have the below array and cannot figure out why it is saying array out of range. any suggestions are appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA DATA.SOURCE_CHECK4 (DROP=I);&lt;BR /&gt;SET DATA.SOURCE_CHECK3;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;FORMAT SOURCE $10.;&lt;BR /&gt;ARRAY DTP [8] DTPSRC1-DTPSRC8;&lt;BR /&gt;ARRAY OPV [8] OPVSRC1-OPVSRC8;&lt;BR /&gt;ARRAY MMR [8] MMRSRC1-MMRSRC8;&lt;BR /&gt;ARRAY HIB [6] HIBSRC1-HIBSRC6;&lt;BR /&gt;ARRAY HBV [7] HBVSRC2-HBVSRC8; /*GETTING RID OF BIRTHDOSE HBV*/&lt;BR /&gt;ARRAY VAX [8] VAXSRC1-VAXSRC8;&lt;BR /&gt;ARRAY STP [8] STPSRC1-STPSRC8;&lt;BR /&gt;ARRAY FLU [8] FLUSRC1-FLUSRC8;&lt;BR /&gt;ARRAY HAV [8] HAVSRC1-HAVSRC8;&lt;BR /&gt;ARRAY RTV [6] RTVSRC1-RTVSRC6;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DO I= 1 TO 75;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IF (DTP[I] = 1 OR DTP[I]=.) AND (OPV[I] = 1 OR OPV[I]=.) AND (MMR[I] = 1 OR MMR[I]=.) AND&lt;BR /&gt;(HIB[I] = 1 OR HIB[I]=.) AND (HBV[I] = 1 OR HBV[I]=.) AND (VAX[I] = 1 OR VAX[I]=.) AND&lt;BR /&gt;(STP[I] = 1 OR STP[I]=.) AND (FLU[I] = 1 OR FLU[I]=.) AND (HAV[I] = 1 OR HAV[I]=.) AND&lt;BR /&gt;(RTV[I] = 1 OR RTV[I]=.) THEN SOURCE="HD ONLY";&lt;BR /&gt;ELSE IF&lt;BR /&gt;(DTP[I] = 0 OR DTP[I]=.) AND (OPV[I] = 0 OR OPV[I]=.) AND (MMR[I] = 0 OR MMR[I]=.) AND&lt;BR /&gt;(HIB[I] = 0 OR HIB[I]=.) AND (HBV[I] = 0 OR HBV[I]=.) AND (VAX[I] = 0 OR VAX[I]=.) AND&lt;BR /&gt;(STP[I] = 0 OR STP[I]=.) AND (FLU[I] = 0 OR FLU[I]=.) AND (HAV[I] = 0 OR HAV[I]=.) AND&lt;BR /&gt;(RTV[I] = 0 OR RTV[I]=.) THEN SOURCE="MED ONLY";&lt;BR /&gt;ELSE IF&lt;BR /&gt;(DTP[I]=.) AND (OPV[I]=.) AND (MMR[I]=.) AND&lt;BR /&gt;(HIB[I]=.) AND (HBV[I]=.) AND (VAX[I]=.) AND&lt;BR /&gt;(STP[I]=.) AND (FLU[I]=.) AND (HAV[I]=.) AND&lt;BR /&gt;(RTV[I]=.) THEN SOURCE="MISSING";&lt;BR /&gt;ELSE SOURCE="BOTH";&lt;BR /&gt;END;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 19:09:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ARRAY-subscript-out-of-range/m-p/570712#M75253</guid>
      <dc:creator>TPayne</dc:creator>
      <dc:date>2019-07-02T19:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: ARRAY subscript out of range</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ARRAY-subscript-out-of-range/m-p/570718#M75254</link>
      <description>&lt;P&gt;No miracle. The maximum size of any array is 8, while you try to iterate i up to 75.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 19:14:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ARRAY-subscript-out-of-range/m-p/570718#M75254</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-02T19:14:24Z</dc:date>
    </item>
    <item>
      <title>Re: ARRAY subscript out of range</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ARRAY-subscript-out-of-range/m-p/570720#M75255</link>
      <description>&lt;P&gt;your are defining DTP with 8 elements in it (&lt;SPAN&gt;ARRAY DTP [8] DTPSRC1-DTPSRC8;)&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The way you have written do loop it is expecting 75 elements.&amp;nbsp;DO I= 1 TO 75;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 19:15:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ARRAY-subscript-out-of-range/m-p/570720#M75255</guid>
      <dc:creator>smijoss1</dc:creator>
      <dc:date>2019-07-02T19:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: ARRAY subscript out of range</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ARRAY-subscript-out-of-range/m-p/570721#M75256</link>
      <description>&lt;P&gt;i goes to 75 but each of your arrays only has 7 or 8 elements.&lt;/P&gt;
&lt;P&gt;I don't know what you think is happening, but it's not correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/278418"&gt;@TPayne&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;i have a dataset of dummy variables (0,1, .) that I want to use to determine the value of a new variable, "source". I have the below array and cannot figure out why it is saying array out of range. any suggestions are appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA DATA.SOURCE_CHECK4 (DROP=I);&lt;BR /&gt;SET DATA.SOURCE_CHECK3;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;FORMAT SOURCE $10.;&lt;BR /&gt;ARRAY DTP [8] DTPSRC1-DTPSRC8;&lt;BR /&gt;ARRAY OPV [8] OPVSRC1-OPVSRC8;&lt;BR /&gt;ARRAY MMR [8] MMRSRC1-MMRSRC8;&lt;BR /&gt;ARRAY HIB [6] HIBSRC1-HIBSRC6;&lt;BR /&gt;ARRAY HBV [7] HBVSRC2-HBVSRC8; /*GETTING RID OF BIRTHDOSE HBV*/&lt;BR /&gt;ARRAY VAX [8] VAXSRC1-VAXSRC8;&lt;BR /&gt;ARRAY STP [8] STPSRC1-STPSRC8;&lt;BR /&gt;ARRAY FLU [8] FLUSRC1-FLUSRC8;&lt;BR /&gt;ARRAY HAV [8] HAVSRC1-HAVSRC8;&lt;BR /&gt;ARRAY RTV [6] RTVSRC1-RTVSRC6;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DO I= 1 TO 75;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF (DTP[I] = 1 OR DTP[I]=.) AND (OPV[I] = 1 OR OPV[I]=.) AND (MMR[I] = 1 OR MMR[I]=.) AND&lt;BR /&gt;(HIB[I] = 1 OR HIB[I]=.) AND (HBV[I] = 1 OR HBV[I]=.) AND (VAX[I] = 1 OR VAX[I]=.) AND&lt;BR /&gt;(STP[I] = 1 OR STP[I]=.) AND (FLU[I] = 1 OR FLU[I]=.) AND (HAV[I] = 1 OR HAV[I]=.) AND&lt;BR /&gt;(RTV[I] = 1 OR RTV[I]=.) THEN SOURCE="HD ONLY";&lt;BR /&gt;ELSE IF&lt;BR /&gt;(DTP[I] = 0 OR DTP[I]=.) AND (OPV[I] = 0 OR OPV[I]=.) AND (MMR[I] = 0 OR MMR[I]=.) AND&lt;BR /&gt;(HIB[I] = 0 OR HIB[I]=.) AND (HBV[I] = 0 OR HBV[I]=.) AND (VAX[I] = 0 OR VAX[I]=.) AND&lt;BR /&gt;(STP[I] = 0 OR STP[I]=.) AND (FLU[I] = 0 OR FLU[I]=.) AND (HAV[I] = 0 OR HAV[I]=.) AND&lt;BR /&gt;(RTV[I] = 0 OR RTV[I]=.) THEN SOURCE="MED ONLY";&lt;BR /&gt;ELSE IF&lt;BR /&gt;(DTP[I]=.) AND (OPV[I]=.) AND (MMR[I]=.) AND&lt;BR /&gt;(HIB[I]=.) AND (HBV[I]=.) AND (VAX[I]=.) AND&lt;BR /&gt;(STP[I]=.) AND (FLU[I]=.) AND (HAV[I]=.) AND&lt;BR /&gt;(RTV[I]=.) THEN SOURCE="MISSING";&lt;BR /&gt;ELSE SOURCE="BOTH";&lt;BR /&gt;END;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 19:16:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ARRAY-subscript-out-of-range/m-p/570721#M75256</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-02T19:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: ARRAY subscript out of range</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ARRAY-subscript-out-of-range/m-p/570743#M75257</link>
      <description>&lt;P&gt;Thanks! Makes sense- I thought I had to tell it to do an iteration for each array listed!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 19:54:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ARRAY-subscript-out-of-range/m-p/570743#M75257</guid>
      <dc:creator>TPayne</dc:creator>
      <dc:date>2019-07-02T19:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: ARRAY subscript out of range</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ARRAY-subscript-out-of-range/m-p/570752#M75259</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/278418"&gt;@TPayne&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure about the expected result of your data step (note that variable SOURCE would be overwritten in every iteration of the DO loop), but maybe it's similar to what the data step below creates (or you can adapt this step accordingly):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
array x[*] DTPSRC1-DTPSRC8 OPVSRC1-OPVSRC8 MMRSRC1-MMRSRC8 HIBSRC1-HIBSRC6 HBVSRC2-HBVSRC8
           VAXSRC1-VAXSRC8 STPSRC1-STPSRC8 FLUSRC1-FLUSRC8 HAVSRC1-HAVSRC8 RTVSRC1-RTVSRC6;
set data.source_check3;
length source $10;
if n(of x[*])=0 then source="MISSING";
else if 1 in x &amp;amp; 0 ~in x then source="HD ONLY";
else if 0 in x &amp;amp; 1 ~in x then source="MED ONLY";
else source="BOTH";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The logic used here: Variable SOURCE will be&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;"MISSING" if all 75 values are missing&lt;/LI&gt;
&lt;LI&gt;"HD ONLY" if at least one of the values equals 1, but none equals 0&lt;/LI&gt;
&lt;LI&gt;"MED ONLY" if at least one of the values equals 0, but none equals 1&lt;/LI&gt;
&lt;LI&gt;"BOTH" in all other cases (i.e., if at least one of the values equals 0, and at least one equals 1 -- assuming that 0, 1 and . are the only possible values).&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 02 Jul 2019 20:39:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ARRAY-subscript-out-of-range/m-p/570752#M75259</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-07-02T20:39:43Z</dc:date>
    </item>
  </channel>
</rss>

