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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 2 replies
  • 664 views
  • 0 likes
  • 2 in conversation