<?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: Dynamically define array using macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-define-array-using-macro-variable/m-p/147040#M29203</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Left-justify the macro variable when you create it - perhaps you used something like -&lt;/P&gt;&lt;P&gt;CALL SYMPUT('MAXCYC', PUT(n, 8.));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use this instead:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL SYMPUT('MAXCYC', LEFT(PUT(n, 8.)));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively, left-justify when you invoke it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;ARRAY CYC_N{&amp;amp;MAXCYC} CYCLE_1-CYCLE_%LEFT(&amp;amp;MAXCYC);&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 Aug 2014 02:21:20 GMT</pubDate>
    <dc:creator>dkb</dc:creator>
    <dc:date>2014-08-04T02:21:20Z</dc:date>
    <item>
      <title>Dynamically define array using macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-define-array-using-macro-variable/m-p/147039#M29202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wanted to define an array with dynamic Dimension according the real data.&amp;nbsp; I create a macro variable &amp;amp;MAXCYC, and I checked, it had 25 in my program.&amp;nbsp; Now I want to define an array of &amp;amp;MAXCYC dimension with name as CYCLE_1-CYCLE_&amp;amp;MAXCYC.&amp;nbsp; I used the following format, but I got error message:&lt;/P&gt;&lt;P&gt;ARRAY CYC_N{&amp;amp;MAXCYC} CYCLE_1-CYCLE_&amp;amp;MAXCYC;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MESSAGE:&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the macro variable "MAXCYC".&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CYCLE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 200&lt;/P&gt;&lt;P&gt;ERROR: Missing numeric suffix on a numbered variable list (CYCLE1-CYCLE).&lt;/P&gt;&lt;P&gt;ERROR: Too few variables defined for the dimension(s) specified for the array CYC_N.&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, (, ;, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do I solve this issue?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Abdu.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Aug 2014 01:45:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamically-define-array-using-macro-variable/m-p/147039#M29202</guid>
      <dc:creator>Abdu</dc:creator>
      <dc:date>2014-08-04T01:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically define array using macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-define-array-using-macro-variable/m-p/147040#M29203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Left-justify the macro variable when you create it - perhaps you used something like -&lt;/P&gt;&lt;P&gt;CALL SYMPUT('MAXCYC', PUT(n, 8.));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use this instead:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL SYMPUT('MAXCYC', LEFT(PUT(n, 8.)));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively, left-justify when you invoke it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;ARRAY CYC_N{&amp;amp;MAXCYC} CYCLE_1-CYCLE_%LEFT(&amp;amp;MAXCYC);&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Aug 2014 02:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamically-define-array-using-macro-variable/m-p/147040#M29203</guid>
      <dc:creator>dkb</dc:creator>
      <dc:date>2014-08-04T02:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically define array using macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-define-array-using-macro-variable/m-p/147041#M29204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Call symputX instead of call symput&lt;/P&gt;&lt;P&gt;or trim the variable in your SQL step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select trim(count(*)) into :max_count&lt;/P&gt;&lt;P&gt;from blah;&lt;/P&gt;&lt;P&gt;quit; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also consider the wildcard operators if you only have the variables in cycle_1 - cycle_5 starting with cycle_ in the dataset. If you have other variables such as cycle_max then this won't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;array cyc_n(*) cycle_:;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Aug 2014 03:02:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamically-define-array-using-macro-variable/m-p/147041#M29204</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-08-04T03:02:09Z</dc:date>
    </item>
  </channel>
</rss>

