<?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 Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-Array-subscript-out-of-range-at-line/m-p/462237#M29814</link>
    <description>Yes, you are right. thank you very much.</description>
    <pubDate>Tue, 15 May 2018 01:55:34 GMT</pubDate>
    <dc:creator>Jinglin</dc:creator>
    <dc:date>2018-05-15T01:55:34Z</dc:date>
    <item>
      <title>ERROR: Array subscript out of range at line</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-Array-subscript-out-of-range-at-line/m-p/461937#M29780</link>
      <description>&lt;P&gt;&lt;FONT color="#000000" face="Courier New" size="3"&gt;&lt;STRONG&gt;Please find my code below. I'm trying to split the variable SAEEVE to 200 length variables, and it prints out this error. Hoe do I&amp;nbsp;deal with&amp;nbsp;this error?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; supp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;SAEEVE=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5))SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5)) SAETRT= strip (catx('/ ', SAETTXT1, SAETTXT2, SAETTXT3, SAETTXT4, SAETTXT5))"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; chr_str=200;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; supp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symputx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'num_str'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,int((length(SAEEVE)+&amp;amp;chr_str-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;)/&amp;amp;chr_str));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; num=&amp;amp;num_str;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; supp1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; supp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Var[*] $ &amp;amp;chr_str SAEEVE1-SAEEVE&amp;amp;num_str;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;_i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; _j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;do &lt;/FONT&gt;&amp;nbsp;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;until&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (scan(SAEEVE,_I,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;''&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) eq &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;''&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;_w=scan(SAEEVE,_i,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;' '&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; lengthc(var[_j])+lengthc(_w)&amp;gt; lengthc(var[_j]) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; _j+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;var[_j]=strip(var[_j])||&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;''&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;||_w;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;_i+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 07:22:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-Array-subscript-out-of-range-at-line/m-p/461937#M29780</guid>
      <dc:creator>Jinglin</dc:creator>
      <dc:date>2018-05-14T07:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Array subscript out of range at line</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-Array-subscript-out-of-range-at-line/m-p/461942#M29781</link>
      <description>&lt;P&gt;Sorry, you have SAS code in a text variable, and you are then writing macro code to parse it out?&amp;nbsp; Why?&amp;nbsp; This route lies madness.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For splitting to 200 characters, a simple way is to read the characters one by one, then add the word on, and if longer than 200 write out, something like:&lt;/P&gt;
&lt;PRE&gt;data want;
  set supp;
  length word line $200;
  do i=1 to lengthn(saeeve);
    if char(saeeve,i) in (" ",",","(",")") then do;
      if lengthn(catx(" ",line,word)) &amp;gt;= 200 then output;
      line=word;
    end;
    word=cats(word,char(saeeve,i));
  end;
run;&lt;/PRE&gt;
&lt;P&gt;Note note tested, but it will give you a start. However I really advise you consider what you are doing as firstly character strings have limitations, and secondly code can have any number of delimiters, special characters and nuances that your not going to pick up.&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 07:49:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-Array-subscript-out-of-range-at-line/m-p/461942#M29781</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-14T07:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Array subscript out of range at line</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-Array-subscript-out-of-range-at-line/m-p/461953#M29782</link>
      <description>Sorry for making confuse. The text value of SAEEVE was dummied, and please ignore it. This SAEEVE is just refer to one variable which length is over 2000. And I want to split to 200 length limit variables like SAEEVE1 SAEEVE2..etc.&lt;BR /&gt;Actually this error still exist when I remove those special characters, and I really want to know why the error come out.&lt;BR /&gt;Thanks for your reply, and I will try with your method one more time.</description>
      <pubDate>Mon, 14 May 2018 08:20:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-Array-subscript-out-of-range-at-line/m-p/461953#M29782</guid>
      <dc:creator>Jinglin</dc:creator>
      <dc:date>2018-05-14T08:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Array subscript out of range at line</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-Array-subscript-out-of-range-at-line/m-p/461978#M29784</link>
      <description>&lt;P&gt;You really should start following Maxim 1 and read the SAS documentation&lt;/P&gt;
&lt;P&gt;(&lt;A href="http://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.3&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n1kkgqelwql5syn1mr4zx8ia0nup.htm&amp;amp;locale=de" target="_blank"&gt;http://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.3&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n1kkgqelwql5syn1mr4zx8ia0nup.htm&amp;amp;locale=de&lt;/A&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #333333; font-family: AvenirNext, Helvetica, Arial, sans-serif; font-size: 14.08px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: bold; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"&gt;Returns the length of a character string, &lt;FONT size="4"&gt;&lt;U&gt;including trailing blanks&lt;/U&gt;&lt;/FONT&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your _j is incremented &lt;EM&gt;every&lt;/EM&gt; time a "word" is read, and you don't even assign any value to SAEEVE1 (you start with SAEEVE2).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the length() function instead of lengthc() where appropriate:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data supp1;
set supp;
array Var[*] $ &amp;amp;chr_str SAEEVE1-SAEEVE&amp;amp;num_str;
_i = 1;
_j = 1;
do until (scan(SAEEVE,_i,'') eq '');
  _w = scan(SAEEVE,_i,' ');
  if length(var[_j]) + length(_w) &amp;gt; lengthc(var[_j]) then _j + 1;
  var[_j] = strip(var[_j]) || '' || _w;
  _i + 1;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Just like you used %put to reveal the values of macro variables, use put in a data step to show how values develop during data step execution. This will lead you to an understanding where your code does not perform as you want.&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 11:05:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-Array-subscript-out-of-range-at-line/m-p/461978#M29784</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-14T11:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Array subscript out of range at line</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-Array-subscript-out-of-range-at-line/m-p/461986#M29786</link>
      <description>&lt;P&gt;The calculation of how many variables are needed depends only on the length == how many 200-character chunks are needed.&amp;nbsp; But the assignment of values to those variables depends on where blanks are found.&amp;nbsp; That can require an extra variable.&amp;nbsp; To take a simple (perhaps unrealistic example), suppose your original string is 407 characters long:&amp;nbsp; 101 characters then a blank, 101 more characters then a blank, etc.&amp;nbsp; You woud calculate that you need 3 variables.&amp;nbsp; But you actually need 4 variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's no harm in creating an extra variable that might not be needed.&amp;nbsp; Just add 1 to the formula for &amp;amp;NUM_STR.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 11:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-Array-subscript-out-of-range-at-line/m-p/461986#M29786</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-14T11:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Array subscript out of range at line</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-Array-subscript-out-of-range-at-line/m-p/462237#M29814</link>
      <description>Yes, you are right. thank you very much.</description>
      <pubDate>Tue, 15 May 2018 01:55:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-Array-subscript-out-of-range-at-line/m-p/462237#M29814</guid>
      <dc:creator>Jinglin</dc:creator>
      <dc:date>2018-05-15T01:55:34Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Array subscript out of range at line</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-Array-subscript-out-of-range-at-line/m-p/462238#M29815</link>
      <description>Thanks for your example, and it's really useful. You are right.</description>
      <pubDate>Tue, 15 May 2018 01:57:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ERROR-Array-subscript-out-of-range-at-line/m-p/462238#M29815</guid>
      <dc:creator>Jinglin</dc:creator>
      <dc:date>2018-05-15T01:57:18Z</dc:date>
    </item>
  </channel>
</rss>

