DATA Step, Macro, Functions and more

call execute vs SAS macro

Reply
Super Contributor
Posts: 271

call execute vs SAS macro

Under which circumstances call execute is more appropriate than SAS macro since both of them generate SAS codes?

Super User
Posts: 19,770

Re: call execute vs SAS macro

Posted in reply to SAS_inquisitive

If you have the parameters for your macro in a dataset then call execute is a no brainer. 

Beyond that I think some of it comes down to personal preference and readability.  

 

Also, not all macro's can be call execute. 

Respected Advisor
Posts: 4,919

Re: call execute vs SAS macro

@Reeza wrote:


Also, not all macro's can be call execute. 


... Please expand 

PG
Super User
Posts: 5,424

Re: call execute vs SAS macro

What I think @Reeza refers to is the fact that the code (data steps, procs or macro calls) are executed sequentially after the data step that does the call has ended.

This can have impact on the code that is to be executed, like access/creation/updates of common tables, values of macro variables and so on.

Data never sleeps
Respected Advisor
Posts: 4,919

Re: call execute vs SAS macro

So, the advantage of macros programs over code built with call execute would be to allow for later binding?

PG
Super User
Posts: 5,497

Re: call execute vs SAS macro

Posted in reply to SAS_inquisitive

First, just a technical note.  CALL EXECUTE is part of macro language.  Even though it doesn't use % or &, CALL EXECUTE will not work if the macro processor is turned off.

 

If you had to follow one general rule about when to use CALL EXECUTE, it would be this.  CALL EXECUTE is the best tool for the job when a SAS data set contains all the information needed to construct a series of SAS steps, and when information from multiple observations is required to construct those steps.  If anyone were to point out exceptions to that rule, I'm sure I would have to agree because there are exceptions.  But that's the general rule that I follow.

 

Good luck.

Super Contributor
Posts: 271

Re: call execute vs SAS macro

Posted in reply to Astounding

@Astounding Thank you for this information.  I wonder if there is an example that helps to clarify the concept.

Super User
Posts: 19,770

Re: call execute vs SAS macro

Posted in reply to SAS_inquisitive

The example of CALL EXECUTE() in the documentation is really good. 

 

One piece of advice, is to learn how to navigate the SAS documentation, its full of goodies, relatively easy to use and is helpful in pointing out similar functions at the end of a function.

 

Ask a Question
Discussion stats
  • 7 replies
  • 393 views
  • 2 likes
  • 5 in conversation