<?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: arrays defining the &amp;quot;upper bound&amp;quot; or rather last element in the range in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/683378#M206980</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/87761"&gt;@agbpilot&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for your reply and insight.&amp;nbsp; Here is the code in its entirety starting from where I create the macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*-------------------------------------------------------------------------------------------*;&lt;BR /&gt;* Create macro based upon max word count within owner city field *;&lt;BR /&gt;*-------------------------------------------------------------------------------------------*;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;set stacked (keep= owner_city owner_type2);&lt;BR /&gt;where owner_type2 = 'OUT_CNTRY';&lt;/P&gt;
&lt;P&gt;retain maxwords;&lt;/P&gt;
&lt;P&gt;num_words_own_city = countw(owner_city, ' ');&lt;BR /&gt;maxwords=max(maxwords,num_words_own_city);&lt;BR /&gt;num_elements = maxwords + 1;&lt;/P&gt;
&lt;P&gt;call symput('maxwords',maxwords);&lt;BR /&gt;call symput('num_elements',num_elements);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%put&lt;BR /&gt;max word count: &amp;amp;maxwords&lt;BR /&gt;number of search elements: &amp;amp;num_elements&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;*-------------------------------------------------------------------------------------------------------*;&lt;BR /&gt;* Based upon max word count, parse &amp;amp; extract words to new columns for comparison against intl file *;&lt;BR /&gt;*-------------------------------------------------------------------------------------------------------*;&lt;/P&gt;
&lt;P&gt;data intl;&lt;BR /&gt;set stacked;&lt;BR /&gt;length owner_country $2.;&lt;BR /&gt;where owner_type2 = 'OUT_CNTRY';&lt;/P&gt;
&lt;P&gt;/*create an array to represent the words extracted from the owner_city field - count of words is variable*/&lt;/P&gt;
&lt;P&gt;array words_parsed {&amp;amp;maxwords.} $60 ;&lt;/P&gt;
&lt;P&gt;/*iterate through owner city field parsing out word by word untill iterations &amp;gt; the count of words*/&lt;/P&gt;
&lt;P&gt;do i=1 to countw(owner_city, ' ');&lt;BR /&gt;words_parsed{i} = strip(upcase(scan(owner_city, i,' ')));&lt;BR /&gt;end;&lt;/P&gt;
&lt;P&gt;array search_fields {&amp;amp;num_elements.} $60 owner_city words_parsed1-words_parsed&amp;amp;maxwords.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you look closely at the code I provided earlier uses CALL SYMPUTX to prevent leading spaces from appearing. What CALL SYMPUT('maxwords', maxwords) does, in effect, is create a string value from the maxwords with an implied Put(maxwords,&amp;lt;some format&amp;gt;). The format generally used will likely be BEST12. if you don't supply one. Which means the value has a LOT of blanks. Since you posted the log in the main message window the text from your log was reformatted by removing duplicate blanks.&lt;/P&gt;
&lt;P&gt;Here is some example code that shows this behavior. The %put to display the macro variables is sandwiched between pipes to see the start and end more clearly. And the log is copied and pasted into a code window on the forum using the &amp;lt;/&amp;gt; icon to preserve the text formatting.&lt;/P&gt;
&lt;PRE&gt;60   data _null_;
61      call symput('v1',3);
62      call symputx('v2',3);
63   run;

NOTE: Numeric values have been converted to character
      values at the places given by: (Line):(Column).
      61:21
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
64
65   %put V1 is |&amp;amp;v1.|;
V1 is |           3|
66   %put V2 is |&amp;amp;v2.|;
V2 is |3|
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Sep 2020 23:26:33 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-09-11T23:26:33Z</dc:date>
    <item>
      <title>arrays defining the "upper bound" or rather last element in the range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/681084#M205963</link>
      <description>&lt;P&gt;Hi, I'm new to arrays and do loops and I've read through the posts but can't seem to get my code to work as intended.&amp;nbsp; I'm trying to create new variables using an array.&amp;nbsp; Basically, I'm trying to extract the words from a string of words contained within &lt;EM&gt;owner_city&lt;/EM&gt; field.&amp;nbsp; Since the # of words fluctuates across obs I've derived a field,&amp;nbsp;&lt;EM&gt;num_words_own_city&lt;/EM&gt;, using countw.&amp;nbsp; Now, I'm attempting to use this field,&amp;nbsp;&lt;EM&gt;num_words_own_city,&lt;/EM&gt; to define the last element in the range of the array.&amp;nbsp; Can the last element of the array be dynamic across obs based upon a variable count of words within&amp;nbsp;&lt;EM&gt;num_words_own_city&lt;/EM&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm hoping to create new columns (parsed words) vs. new rows.&amp;nbsp; Any ideas or assistance would be much appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Andy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data intl;&lt;BR /&gt;set stacked;&lt;BR /&gt;/*length word $60.; set longest length of word*/&lt;/P&gt;
&lt;P&gt;where owner_type2 = 'OUT_CNTRY' /*; test*/&lt;BR /&gt;and prpty_adrs = '3317 CANYON VALLEY TRL' ;&lt;/P&gt;
&lt;P&gt;/*count words delimited by a space within the owner city field*/&lt;/P&gt;
&lt;P&gt;delim = ' ';&lt;BR /&gt;num_words_own_city = countw(owner_city, delim);&lt;/P&gt;
&lt;P&gt;/*create an array to represent the words extracted from the owner_city field - count of words is variable*/&lt;/P&gt;
&lt;P&gt;array words_parsed {*} $60 words_parsed1-words_parsed(num_words_own_city) ;&lt;/P&gt;
&lt;P&gt;/*iterate through owner city field parsing out word by word untill iterations &amp;gt; the count of words*/&lt;/P&gt;
&lt;P&gt;do i=1 to dim(words_parsed);&lt;BR /&gt;words_parsed{i} = strip(upcase(scan(owner_city, i, delim)));&lt;BR /&gt;/* output;*/&lt;BR /&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 17:17:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/681084#M205963</guid>
      <dc:creator>agbpilot</dc:creator>
      <dc:date>2020-09-02T17:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: arrays defining the "upper bound" or rather last element in the range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/681087#M205966</link>
      <description>Can the last element of the array be dynamic across obs based upon a variable count of words within num_words_own_city?&lt;BR /&gt;&lt;BR /&gt;Unfortunately the answer to that is no &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Some alternatives, in order of preference:&lt;BR /&gt;1. Output each word to a unique line and transpose after via PROC TRANSPOSE (fully dynamic)&lt;BR /&gt;2. Find the maximum number of words in a prior step and set the array using that value &lt;BR /&gt;3. Make the array arbitrarily large and then delete empty variables after the fact&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 02 Sep 2020 17:25:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/681087#M205966</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-09-02T17:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: arrays defining the "upper bound" or rather last element in the range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/681126#M205984</link>
      <description>&lt;P&gt;Hi Reeza, thanks for your reply.&amp;nbsp; I've never used proc transpose.&amp;nbsp; Could you propose sample code that could make option 1 you suggest work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Andy&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 18:30:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/681126#M205984</guid>
      <dc:creator>agbpilot</dc:creator>
      <dc:date>2020-09-02T18:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: arrays defining the "upper bound" or rather last element in the range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/681204#M206028</link>
      <description>&lt;P&gt;If you want the last word, rather than a count of how many words, that's easy:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;lastword = scan(long_string, -1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It's not clear what advantage you get by splitting the text into separate words, however.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 02:54:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/681204#M206028</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-09-03T02:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: arrays defining the "upper bound" or rather last element in the range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/681524#M206145</link>
      <description>&lt;P&gt;An example of &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;'s approach number 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Obviously untested code as I don't have your data set.&lt;/P&gt;
&lt;PRE&gt;data _null_;
   set stacked (keep= owner_city);
   retain maxwords;
   num_words_own_city = countw(owner_city, ' ');
   maxwords=max(maxwords,num_words_own_city);
   Call symputx('maxwords',maxwords);
run;

data intl;
   set stacked;
   /*create an array to represent the words extracted from the owner_city field - count of words is variable*/
   array words_parsed {&amp;amp;maxwords.} $60 ;
   /*iterate through owner city field parsing out word by word untill iterations &amp;gt; the count of words*/
   do i=1 to countw(owner_city);
      words_parsed{i} = strip(upcase(scan(owner_city, i,' ')));
   end;
run;&lt;/PRE&gt;
&lt;P&gt;Absolutely no claims to efficiency but the data _null_ to find the largest number of words should be simple to follow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not quite sure what this gains you but it is your data. I just hope you don't have values I found in some addresses like "see the woman in the back apartment".&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 22:15:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/681524#M206145</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-03T22:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: arrays defining the "upper bound" or rather last element in the range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/681696#M206223</link>
      <description>&lt;P&gt;Ok great, thank you very much!&amp;nbsp; I really appreciate the detailed sample code.&amp;nbsp; Ultimately I'm trying to parse out words within this field which I later compare to an international file, which contains intl city and country names.&amp;nbsp; This will be very helpful b/c these particular intl records are "sloppy" as the intl addresses are being squeezed into U.S. address formats, which they don't naturally fit within.&amp;nbsp; Hence why I have to parse out the words, and then later match the parsed words against the intl file.&amp;nbsp; Let me give it a test run, and again, thank you very much!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Andy&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2020 17:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/681696#M206223</guid>
      <dc:creator>agbpilot</dc:creator>
      <dc:date>2020-09-04T17:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: arrays defining the "upper bound" or rather last element in the range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/681727#M206246</link>
      <description>that did the trick, thanks again!</description>
      <pubDate>Fri, 04 Sep 2020 18:41:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/681727#M206246</guid>
      <dc:creator>agbpilot</dc:creator>
      <dc:date>2020-09-04T18:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: arrays defining the "upper bound" or rather last element in the range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/682733#M206685</link>
      <description>&lt;P&gt;Hi, thanks again for all of your help.&amp;nbsp; As follow up to this string, I'm attempting to define another array from the first array,&amp;nbsp;&lt;EM&gt;words_parsed&lt;/EM&gt;.&amp;nbsp; The second array,&amp;nbsp;&lt;EM&gt;search_fields,&lt;/EM&gt; I'm hoping to use the full range of words being parsed, which is based upon &amp;amp;maxwords macro variable.&amp;nbsp; However, in this new array I want to add an additional field,&amp;nbsp;&lt;EM&gt;owner_city&lt;/EM&gt;, to be a part of the elements.&amp;nbsp; So I created a separate macro,&amp;nbsp;&lt;EM&gt;num_elements&lt;/EM&gt;, which is just &amp;amp;maxwords + 1.&amp;nbsp; However, I'm encountering below log error.&amp;nbsp; I'm not sure how to reference the &amp;amp;maxwords macro when defining the elements in the array.&amp;nbsp; The elements I want to include in the &lt;EM&gt;search_fields&lt;/EM&gt; array are:&amp;nbsp;owner_city words_parsed1-words_parsed(# based upon &amp;amp;maxwords. macro) .&amp;nbsp;&amp;nbsp;Here's the code as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any assistance would be much appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Andy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;set stacked (keep= owner_city owner_type2);&lt;BR /&gt;where owner_type2 = 'OUT_CNTRY';&lt;/P&gt;
&lt;P&gt;retain maxwords;&lt;/P&gt;
&lt;P&gt;num_words_own_city = countw(owner_city, ' ');&lt;BR /&gt;maxwords=max(maxwords,num_words_own_city);&lt;BR /&gt;num_elements = maxwords + 1;&lt;/P&gt;
&lt;P&gt;call symput('maxwords',maxwords);&lt;BR /&gt;call symput('num_elements',num_elements);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%put&lt;BR /&gt;max word count: &amp;amp;maxwords&lt;BR /&gt;number of search elements: &amp;amp;num_elements&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;*-------------------------------------------------------------------------------------------------------*;&lt;BR /&gt;* Based upon max word count, parse &amp;amp; extract words to new columns for comparison against intl file *;&lt;BR /&gt;*-------------------------------------------------------------------------------------------------------*;&lt;/P&gt;
&lt;P&gt;data intl;&lt;BR /&gt;set stacked;&lt;BR /&gt;length owner_country $2.;&lt;BR /&gt;where owner_type2 = 'OUT_CNTRY';&lt;/P&gt;
&lt;P&gt;/*create an array to represent the words extracted from the owner_city field - count of words is variable*/&lt;/P&gt;
&lt;P&gt;array words_parsed {&amp;amp;maxwords.} $60 ;&lt;/P&gt;
&lt;P&gt;/*iterate through owner city field parsing out word by word untill iterations &amp;gt; the count of words*/&lt;/P&gt;
&lt;P&gt;do i=1 to countw(owner_city, ' ');&lt;BR /&gt;words_parsed{i} = strip(upcase(scan(owner_city, i,' ')));&lt;BR /&gt;end;&lt;/P&gt;
&lt;P&gt;array search_fields {&amp;amp;num_elements.} $60 /*owner_city words_parsed1 words_parsed2 words_parsed3*/ owner_city words_parsed1-words_parsed{&amp;amp;maxwords.};&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;39 array search_fields {&amp;amp;num_elements.} $60 /*owner_city words_parsed1 words_parsed2 words_parsed3*/ owner_city&lt;BR /&gt;39 ! words_parsed1-words_parsed{&amp;amp;maxwords.};&lt;BR /&gt;_&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, (, ;, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_.&lt;/P&gt;
&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2020 19:00:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/682733#M206685</guid>
      <dc:creator>agbpilot</dc:creator>
      <dc:date>2020-09-09T19:00:42Z</dc:date>
    </item>
    <item>
      <title>Re: arrays defining the "upper bound" or rather last element in the range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/682747#M206691</link>
      <description>&lt;P&gt;In the statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array search_fields {&amp;amp;num_elements.} $60
  /*owner_city words_parsed1 words_parsed2 words_parsed3*/
    owner_city words_parsed1-words_parsed{&amp;amp;maxwords.};
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; get rid of the braces at the end.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change it to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array search_fields {&amp;amp;num_elements.} $60
  /*owner_city words_parsed1 words_parsed2 words_parsed3*/
    owner_city words_parsed1-words_parsed&amp;amp;maxwords.;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can't have namelists of the from&amp;nbsp;&amp;nbsp;&amp;nbsp; X1-X{30}.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; It should be&amp;nbsp; X1-X30.&lt;BR /&gt;&amp;nbsp;words_parsed1-words_parsed&amp;amp;maxwords.;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Sep 2020 04:07:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/682747#M206691</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-09-12T04:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: arrays defining the "upper bound" or rather last element in the range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/683330#M206950</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&amp;nbsp;Thank you for your helpful suggestions.&amp;nbsp; It's probably operator error...&amp;nbsp; I attempted implementing the revised code, see below.&amp;nbsp; However, the log error makes it seem that the macro variable, &amp;amp;maxwords., is not being referenced properly in the numbered variable list within the array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Revised code:&lt;/P&gt;
&lt;P&gt;data intl;&lt;BR /&gt;set stacked;&lt;BR /&gt;length owner_country $2.;&lt;BR /&gt;where owner_type2 = 'OUT_CNTRY';&lt;/P&gt;
&lt;P&gt;/*create an array to represent the words extracted from the owner_city field - count of words is variable*/&lt;/P&gt;
&lt;P&gt;array words_parsed {&amp;amp;maxwords.} $60 ;&lt;/P&gt;
&lt;P&gt;/*iterate through owner city field parsing out word by word untill iterations &amp;gt; the count of words*/&lt;/P&gt;
&lt;P&gt;do i=1 to countw(owner_city, ' ');&lt;BR /&gt;words_parsed{i} = strip(upcase(scan(owner_city, i,' ')));&lt;BR /&gt;end;&lt;/P&gt;
&lt;P&gt;array search_fields {&amp;amp;num_elements.} $60 owner_city words_parsed1-words_parsed&amp;amp;maxwords.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;P&gt;24 data intl;&lt;BR /&gt;25 set stacked;&lt;BR /&gt;26 length owner_country $2.;&lt;BR /&gt;27 where owner_type2 = 'OUT_CNTRY';&lt;BR /&gt;28 &lt;BR /&gt;29 /*create an array to represent the words extracted from the owner_city field - count of words is variable*/&lt;BR /&gt;30 &lt;BR /&gt;31 array words_parsed {&amp;amp;maxwords.} $60 ;&lt;BR /&gt;32 &lt;BR /&gt;33 /*iterate through owner city field parsing out word by word untill iterations &amp;gt; the count of words*/&lt;BR /&gt;34 &lt;BR /&gt;35 do i=1 to countw(owner_city, ' ');&lt;BR /&gt;36 words_parsed{i} = strip(upcase(scan(owner_city, i,' ')));&lt;BR /&gt;37 end;&lt;BR /&gt;38 &lt;BR /&gt;39 array search_fields {&amp;amp;num_elements.} $60 owner_city words_parsed1-words_parsed&amp;amp;maxwords;&lt;BR /&gt;NOTE: Line generated by the macro variable "MAXWORDS".&lt;BR /&gt;39 words_parsed 3&lt;BR /&gt;_&lt;BR /&gt;22&lt;BR /&gt;200&lt;BR /&gt;ERROR: Missing numeric suffix on a numbered variable list (words_parsed1-words_parsed).&lt;BR /&gt;ERROR: Too few variables defined for the dimension(s) specified for the array search_fields.&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, (, ;, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_.&lt;/P&gt;
&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2020 18:37:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/683330#M206950</guid>
      <dc:creator>agbpilot</dc:creator>
      <dc:date>2020-09-11T18:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: arrays defining the "upper bound" or rather last element in the range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/683339#M206956</link>
      <description>&lt;P&gt;I'm afraid that you need to provide the starting data and how you created the Maxwords and Num_element macro variables. It appears as if somehow you have created &amp;amp;maxwords to include a leading space. The space wouldn't cause an issue with an array statement as the index size as SAS will treat&amp;nbsp; { 3} {3} { 3 } the same. However if you make a variable name such as "words_parsed&amp;amp;maxwords" the space would yield "words_parsed 3" which is not a valid variable.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2020 19:28:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/683339#M206956</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-11T19:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: arrays defining the "upper bound" or rather last element in the range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/683370#M206973</link>
      <description>&lt;P&gt;Thank you for your reply and insight.&amp;nbsp; Here is the code in its entirety starting from where I create the macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*-------------------------------------------------------------------------------------------*;&lt;BR /&gt;* Create macro based upon max word count within owner city field *;&lt;BR /&gt;*-------------------------------------------------------------------------------------------*;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;set stacked (keep= owner_city owner_type2);&lt;BR /&gt;where owner_type2 = 'OUT_CNTRY';&lt;/P&gt;
&lt;P&gt;retain maxwords;&lt;/P&gt;
&lt;P&gt;num_words_own_city = countw(owner_city, ' ');&lt;BR /&gt;maxwords=max(maxwords,num_words_own_city);&lt;BR /&gt;num_elements = maxwords + 1;&lt;/P&gt;
&lt;P&gt;call symput('maxwords',maxwords);&lt;BR /&gt;call symput('num_elements',num_elements);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%put&lt;BR /&gt;max word count: &amp;amp;maxwords&lt;BR /&gt;number of search elements: &amp;amp;num_elements&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;*-------------------------------------------------------------------------------------------------------*;&lt;BR /&gt;* Based upon max word count, parse &amp;amp; extract words to new columns for comparison against intl file *;&lt;BR /&gt;*-------------------------------------------------------------------------------------------------------*;&lt;/P&gt;
&lt;P&gt;data intl;&lt;BR /&gt;set stacked;&lt;BR /&gt;length owner_country $2.;&lt;BR /&gt;where owner_type2 = 'OUT_CNTRY';&lt;/P&gt;
&lt;P&gt;/*create an array to represent the words extracted from the owner_city field - count of words is variable*/&lt;/P&gt;
&lt;P&gt;array words_parsed {&amp;amp;maxwords.} $60 ;&lt;/P&gt;
&lt;P&gt;/*iterate through owner city field parsing out word by word untill iterations &amp;gt; the count of words*/&lt;/P&gt;
&lt;P&gt;do i=1 to countw(owner_city, ' ');&lt;BR /&gt;words_parsed{i} = strip(upcase(scan(owner_city, i,' ')));&lt;BR /&gt;end;&lt;/P&gt;
&lt;P&gt;array search_fields {&amp;amp;num_elements.} $60 owner_city words_parsed1-words_parsed&amp;amp;maxwords.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2020 22:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/683370#M206973</guid>
      <dc:creator>agbpilot</dc:creator>
      <dc:date>2020-09-11T22:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: arrays defining the "upper bound" or rather last element in the range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/683371#M206974</link>
      <description>Use call symputX not call symput() to remove leading and trailing spaces.</description>
      <pubDate>Fri, 11 Sep 2020 22:41:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/683371#M206974</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-09-11T22:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: arrays defining the "upper bound" or rather last element in the range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/683378#M206980</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/87761"&gt;@agbpilot&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for your reply and insight.&amp;nbsp; Here is the code in its entirety starting from where I create the macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*-------------------------------------------------------------------------------------------*;&lt;BR /&gt;* Create macro based upon max word count within owner city field *;&lt;BR /&gt;*-------------------------------------------------------------------------------------------*;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;set stacked (keep= owner_city owner_type2);&lt;BR /&gt;where owner_type2 = 'OUT_CNTRY';&lt;/P&gt;
&lt;P&gt;retain maxwords;&lt;/P&gt;
&lt;P&gt;num_words_own_city = countw(owner_city, ' ');&lt;BR /&gt;maxwords=max(maxwords,num_words_own_city);&lt;BR /&gt;num_elements = maxwords + 1;&lt;/P&gt;
&lt;P&gt;call symput('maxwords',maxwords);&lt;BR /&gt;call symput('num_elements',num_elements);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%put&lt;BR /&gt;max word count: &amp;amp;maxwords&lt;BR /&gt;number of search elements: &amp;amp;num_elements&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;*-------------------------------------------------------------------------------------------------------*;&lt;BR /&gt;* Based upon max word count, parse &amp;amp; extract words to new columns for comparison against intl file *;&lt;BR /&gt;*-------------------------------------------------------------------------------------------------------*;&lt;/P&gt;
&lt;P&gt;data intl;&lt;BR /&gt;set stacked;&lt;BR /&gt;length owner_country $2.;&lt;BR /&gt;where owner_type2 = 'OUT_CNTRY';&lt;/P&gt;
&lt;P&gt;/*create an array to represent the words extracted from the owner_city field - count of words is variable*/&lt;/P&gt;
&lt;P&gt;array words_parsed {&amp;amp;maxwords.} $60 ;&lt;/P&gt;
&lt;P&gt;/*iterate through owner city field parsing out word by word untill iterations &amp;gt; the count of words*/&lt;/P&gt;
&lt;P&gt;do i=1 to countw(owner_city, ' ');&lt;BR /&gt;words_parsed{i} = strip(upcase(scan(owner_city, i,' ')));&lt;BR /&gt;end;&lt;/P&gt;
&lt;P&gt;array search_fields {&amp;amp;num_elements.} $60 owner_city words_parsed1-words_parsed&amp;amp;maxwords.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you look closely at the code I provided earlier uses CALL SYMPUTX to prevent leading spaces from appearing. What CALL SYMPUT('maxwords', maxwords) does, in effect, is create a string value from the maxwords with an implied Put(maxwords,&amp;lt;some format&amp;gt;). The format generally used will likely be BEST12. if you don't supply one. Which means the value has a LOT of blanks. Since you posted the log in the main message window the text from your log was reformatted by removing duplicate blanks.&lt;/P&gt;
&lt;P&gt;Here is some example code that shows this behavior. The %put to display the macro variables is sandwiched between pipes to see the start and end more clearly. And the log is copied and pasted into a code window on the forum using the &amp;lt;/&amp;gt; icon to preserve the text formatting.&lt;/P&gt;
&lt;PRE&gt;60   data _null_;
61      call symput('v1',3);
62      call symputx('v2',3);
63   run;

NOTE: Numeric values have been converted to character
      values at the places given by: (Line):(Column).
      61:21
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
64
65   %put V1 is |&amp;amp;v1.|;
V1 is |           3|
66   %put V2 is |&amp;amp;v2.|;
V2 is |3|
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2020 23:26:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/683378#M206980</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-11T23:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: arrays defining the "upper bound" or rather last element in the range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/683445#M207012</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp; excellent!&amp;nbsp; thank you both.&amp;nbsp; it works!&lt;/P&gt;</description>
      <pubDate>Sat, 12 Sep 2020 15:29:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-defining-the-quot-upper-bound-quot-or-rather-last-element/m-p/683445#M207012</guid>
      <dc:creator>agbpilot</dc:creator>
      <dc:date>2020-09-12T15:29:33Z</dc:date>
    </item>
  </channel>
</rss>

