Anyone have any idea why I'm having an issue (Array subscript out of range error) with the following code? All the required variables are there. The syntax looks right. Any clues?
%MACRO GENFLOWVAR;
DATA TMP_FA2; SET TMP_FA2;
ARRAY FLOWS FLOW0-FLOW33;
ARRAY FS F0-F33;
%DO I= 3 %TO 30;
FLOWS[&I]=MEAN(FS[%EVAL(&I-3)],FS[%EVAL(&I-2)],FS[&I],FS[%EVAL(&I+1)],FS[%EVAL(&I+2)],FS[%EVAL(&I+3)]);
%END;
%MEND;%GENFLOWVAR;
why are you using a macro do loop???? There is no need;
do i = 3 to 30;
FLOWS=MEAN(FS[i-3],FS[I-2],FS,FS[I+1],FS[I+2],FS[i+3];
end;
should work just fine.
add options mprint; before your macro call %genflowvar and examine the resulting generated code.
why are you using a macro do loop???? There is no need;
do i = 3 to 30;
FLOWS=MEAN(FS[i-3],FS[I-2],FS,FS[I+1],FS[I+2],FS[i+3];
end;
should work just fine.
add options mprint; before your macro call %genflowvar and examine the resulting generated code.
Thanks for the help
Without your source data it's difficult to say, but note:
Thanks for the help.
The array elements are named F0-F33, but the array subscript still has to range from 1 to 34, not from 0 to 33. It is illegal (array subscript out of range) to ask for FS[0] in your program. If you would like the array subscript to range from 0 to 33, you have to define the array slightly differently:
array FS {0:33} FS0-FS33;
Thanks for the help
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.