I'm stumped.
In the example below i have created the variables B1, B2, B3, B4 and B5. They have the values 1,5,2,6 and 3 respectively.
I have also created the variables M1, M2, M3, M4 and M5 using an array which I want to take the following values.
M1=B1;
M2=max(of B1-B2);
M3=max(of B1-B3) etc...
I need to do this within the do loop for various reasons which I won't go into now. Anyway, this code looks to me like it should work fine. But it doesn't. It looks like the Call Symput doesn't create the global variable &bobno until the datastep has finished running, I need the variable to be created during the do loop to ensure that the correct B1-B&bobno is created to give the correct value in M1-M5.
Help?
Sample Code:
data play;
array bob(5) B1-B5;
do i=1 to 5;
bob(i)=i*i;
end;
array maxi(5) M1-M5;
do i=1 to 5;
call symput ('bobno',compress('B'||i));
maxi(i)=max(of B1-&bobno);
end;
run;
In the example below i have created the variables B1, B2, B3, B4 and B5. They have the values 1,5,2,6 and 3 respectively.
I have also created the variables M1, M2, M3, M4 and M5 using an array which I want to take the following values.
M1=B1;
M2=max(of B1-B2);
M3=max(of B1-B3) etc...
I need to do this within the do loop for various reasons which I won't go into now. Anyway, this code looks to me like it should work fine. But it doesn't. It looks like the Call Symput doesn't create the global variable &bobno until the datastep has finished running, I need the variable to be created during the do loop to ensure that the correct B1-B&bobno is created to give the correct value in M1-M5.
Help?
Sample Code:
data play;
array bob(5) B1-B5;
do i=1 to 5;
bob(i)=i*i;
end;
array maxi(5) M1-M5;
do i=1 to 5;
call symput ('bobno',compress('B'||i));
maxi(i)=max(of B1-&bobno);
end;
run;