<?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 array - too few variables defined in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/array-too-few-variables-defined/m-p/376067#M276567</link>
    <description>&lt;P&gt;I'm trying to run the following bitpack decoder. A macro is called:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro decoderloop_v1(var);
*call missing(decod);*this here causes intantiation or decod as scalar not array;
array mask[9] _temporary_ (1 2 4 8 16 8160 1040384 66060288 4227858432);
array start_bit_pos[9] _temporary_ (0:5 13 20 26);
array decod[9];
call pokelong(repeat(put(0,rb8.),8),addrlong(decod[1]),72);
*initialize values of decod to all 0, replaces bad call missing and array defaults which do not reinitialize upon data step iteration;
do _n_=1 to 9;*no macro loop, loop in data step instead of generating repeated code;
decod[_n_]=brshift(band(mask[_n_],&amp;amp;var),start_bit_pos[_n_]);
end;
%mend decoderloop_v1;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The above macro is called from the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WORK.QUERY_FOR_GETS_DW_EOA_FAULTS;
	%decoderloop_v1(SUBID_IN_HEX);

	SET WORK.QUERY_FOR_GETS_DW_EOA_FAULTS;
	SUBID_IN_HEX = SUBID ;
	FORMAT SUBID_IN_HEX $hex.;
	array SUBID_Decoded{9}  decod;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;229 array SUBID_Decoded{9} decod;&lt;BR /&gt;ERROR: Too few variables defined for the dimension(s) specified for the array SUBID_Decoded.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me debug the code. Thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jul 2017 15:27:35 GMT</pubDate>
    <dc:creator>capam</dc:creator>
    <dc:date>2017-07-14T15:27:35Z</dc:date>
    <item>
      <title>array - too few variables defined</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-too-few-variables-defined/m-p/376067#M276567</link>
      <description>&lt;P&gt;I'm trying to run the following bitpack decoder. A macro is called:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro decoderloop_v1(var);
*call missing(decod);*this here causes intantiation or decod as scalar not array;
array mask[9] _temporary_ (1 2 4 8 16 8160 1040384 66060288 4227858432);
array start_bit_pos[9] _temporary_ (0:5 13 20 26);
array decod[9];
call pokelong(repeat(put(0,rb8.),8),addrlong(decod[1]),72);
*initialize values of decod to all 0, replaces bad call missing and array defaults which do not reinitialize upon data step iteration;
do _n_=1 to 9;*no macro loop, loop in data step instead of generating repeated code;
decod[_n_]=brshift(band(mask[_n_],&amp;amp;var),start_bit_pos[_n_]);
end;
%mend decoderloop_v1;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The above macro is called from the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WORK.QUERY_FOR_GETS_DW_EOA_FAULTS;
	%decoderloop_v1(SUBID_IN_HEX);

	SET WORK.QUERY_FOR_GETS_DW_EOA_FAULTS;
	SUBID_IN_HEX = SUBID ;
	FORMAT SUBID_IN_HEX $hex.;
	array SUBID_Decoded{9}  decod;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;229 array SUBID_Decoded{9} decod;&lt;BR /&gt;ERROR: Too few variables defined for the dimension(s) specified for the array SUBID_Decoded.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me debug the code. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2017 15:27:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-too-few-variables-defined/m-p/376067#M276567</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2017-07-14T15:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: array - too few variables defined</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-too-few-variables-defined/m-p/376079#M276569</link>
      <description>&lt;P&gt;The latest style of arrays (in use for about 30 years now) does not permit you to use an array as an element of another array. &amp;nbsp;The older style did. &amp;nbsp;So if you know your way around arrays, you could try switching to the ancient style of defining arrays. &amp;nbsp;This has a chance of working:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array SUBID&amp;nbsp;(_i_) decode;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I shortened the length of the array name, since I'm not sure that the older style of arrays permits array names longer than 8 characters. &amp;nbsp;I can't test it right now but it might be OK with the original name SUBID_Decoded.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Better yet, just stick to the current style of defining arrays:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array SUBID_Decoded {9} decod1-decod9;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or even better yet, don't bother defining SUBID_Decoded at all. &amp;nbsp;Just program with the existing array named decod. &amp;nbsp;There's really no need to define an additional array holding the exact same elements.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2017 15:57:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-too-few-variables-defined/m-p/376079#M276569</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-14T15:57:52Z</dc:date>
    </item>
  </channel>
</rss>

