Desktop productivity for business analysts and programmers

Calling multiple macros within a data _null_ statement

Accepted Solution Solved
Reply
Occasional Contributor mgm
Occasional Contributor
Posts: 10
Accepted Solution

Calling multiple macros within a data _null_ statement

I'm having trouble calling  3 different macros in a sequence within a data _null_ step. Here is a code snippet :

DATA _NULL_;

SET DATES;

if x = 'A' then call execute ('%runA('||rebal||')');

if x = 'B' then call execute ('%runB('||rebal||')');

if x = 'C' then call execute ('%runC('||rebal||')');

run;

Essentially x is in a sequence 'A','B','C','A','B','C','A','B','C','A','B','C'. Since the execute statement runs at the end of the data step there is no guarantee that the three steps are running in the right sequence.  steps in %runB depend on %runA to complete and steps in %runC depend on %runB to complete... 

 

Let me know ?

 


Accepted Solutions
Solution
‎05-12-2016 11:35 AM
Trusted Advisor
Posts: 1,116

Re: Calling multiple macros within a data _null_ statement

Hi @mgm,

 

The late Roland Rashleigh-Berry recommended to mask macro calls in CALL EXECUTE with %NRSTR in order to prevent premature execution: http://www.datasavantconsulting.com/roland/call_exec.html

 

So, you could try if 

if x = 'A' then call execute ('%nrstr(%runA('||rebal||'))');

etc. works better.

View solution in original post


All Replies
Solution
‎05-12-2016 11:35 AM
Trusted Advisor
Posts: 1,116

Re: Calling multiple macros within a data _null_ statement

Hi @mgm,

 

The late Roland Rashleigh-Berry recommended to mask macro calls in CALL EXECUTE with %NRSTR in order to prevent premature execution: http://www.datasavantconsulting.com/roland/call_exec.html

 

So, you could try if 

if x = 'A' then call execute ('%nrstr(%runA('||rebal||'))');

etc. works better.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 218 views
  • 1 like
  • 2 in conversation