BookmarkSubscribeRSS Feed
capam
Pyrite | Level 9

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;
decod[_n_]=brshift(band(mask[_n_],&var),start_bit_pos[_n_]);
end;
%mend decoderloop_v1;

The above macro is called from the following:

 

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;

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.

1 REPLY 1
Astounding
PROC Star

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1214 views
  • 1 like
  • 2 in conversation