BookmarkSubscribeRSS Feed
SachinRuk
Calcite | Level 5
array time_interval{4}$ 10 ('month','month3','annual','ytd');
do i=1 to 4;
%get_calcs(time_interval{i});
end;

Hi all,

In the abover code the macro get_calcs appends variables with month or whichever name you parse onto it (and it works when i send it when individually typed as month, month3 etc.). However, when I use the array it takes it to be the literal array name instead of value. How do I get arround this?

Thanks,
Sachin
p.s. I do know that this has a lot to do with the fact that macros are invoked before the rest of the code. I just want a work around preferably using arrays.
2 REPLIES 2
MHomes
Calcite | Level 5
Hi Sachin,

Yes you are correct in that the macro processor processes the macro before the data step compiler. As such you need to use the data step routine, call execute to invoke your macro instead.

The following code should do what you want...

array time_interval{4}$ 10 ('month','month3','annual','ytd');
do i=1 to 4;
call execute('%get_calcs(' || time_interval{i} || ')');
end;

I hope this helps.

Cheers,
Michelle
SachinRuk
Calcite | Level 5
Hi Michelle,

It helped to some extent. The problem being that call execute waits till data step is finished running, where my variables are no longer in scope. If you want to follow up the error I've posted my new error on:
http://support.sas.com/forums/thread.jspa?threadID=11674&tstart=0

Regardless, thanks for your help. Seems like its on the right track though.
Sachin

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 805 views
  • 0 likes
  • 2 in conversation