array - too few variables defined

Frequent Contributor
Posts: 77

array - too few variables defined

I'm trying to run the following bitpack decoder. A macro is called:


%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;
%mend decoderloop_v1;

The above macro is called from the following:



	array SUBID_Decoded{9}  decod;

I get the following error:


229 array SUBID_Decoded{9} decod;
ERROR: Too few variables defined for the dimension(s) specified for the array SUBID_Decoded.


Please help me debug the code. Thanks.

Super User
Posts: 6,632

Re: array - too few variables defined

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.  The older style did.  So if you know your way around arrays, you could try switching to the ancient style of defining arrays.  This has a chance of working:


array SUBID (_i_) decode;


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.  I can't test it right now but it might be OK with the original name SUBID_Decoded.


Better yet, just stick to the current style of defining arrays:


array SUBID_Decoded {9} decod1-decod9;


Or even better yet, don't bother defining SUBID_Decoded at all.  Just program with the existing array named decod.  There's really no need to define an additional array holding the exact same elements.

Ask a Question
Discussion stats
  • 1 reply
  • 1 like
  • 2 in conversation