BookmarkSubscribeRSS Feed
SAS_inquisitive
Lapis Lazuli | Level 10

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

7 REPLIES 7
Reeza
Super User

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. 

PGStats
Opal | Level 21

@Reeza wrote:


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


... Please expand 

PG
LinusH
Tourmaline | Level 20

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
PGStats
Opal | Level 21

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

PG
Astounding
PROC Star

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.

SAS_inquisitive
Lapis Lazuli | Level 10

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

Reeza
Super User

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.

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

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
  • 7 replies
  • 1179 views
  • 2 likes
  • 5 in conversation