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
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.
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.