Under which circumstances call execute is more appropriate than SAS macro since both of them generate SAS codes?
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.
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.
So, the advantage of macros programs over code built with call execute would be to allow for later binding?
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.
@Astounding Thank you for this information. I wonder if there is an example that helps to clarify the concept.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.