BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mgm
Fluorite | Level 6 mgm
Fluorite | Level 6

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 ?

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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

1 REPLY 1
FreelanceReinh
Jade | Level 19

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.

sas-innovate-2024.png

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.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1 reply
  • 938 views
  • 1 like
  • 2 in conversation