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

Hello Forum,

I have come across some sas papers that emphasizes the use of call execute rather than SAS macro.  Are there any specific circumstances where call execute is more preferable than  SAS macro.  Thanks for your insights.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

No, the point of call execute is to avoid call symput and the creation of extra macro variables.

This may not be the best example but suppose you need to read in multiple text files from DIFFERENT* directories all with the same file structure.

You can use OS commands to generate a list of all the files and store that in a dataset, so you now have a dataset (FILELIST1) that contains all the files you need to read. If you used a macro to loop you'd need to create macro variables for each filename and loop through.

If you used call execute you could feed the filename as a variable to a different macro without having to create the macro variable.

*If the files were in the same directory wildcards allow for a more efficient solution.

View solution in original post

6 REPLIES 6
Reeza
Super User

My thoughts, call execute is preferable when your macro is driven by data that is stored in a data set.

kaushal2040
Calcite | Level 5

Hi Reeza,

Can you give an example?  Do you mean use of data step interface such as call symput?

Thanks !!!

Reeza
Super User

No, the point of call execute is to avoid call symput and the creation of extra macro variables.

This may not be the best example but suppose you need to read in multiple text files from DIFFERENT* directories all with the same file structure.

You can use OS commands to generate a list of all the files and store that in a dataset, so you now have a dataset (FILELIST1) that contains all the files you need to read. If you used a macro to loop you'd need to create macro variables for each filename and loop through.

If you used call execute you could feed the filename as a variable to a different macro without having to create the macro variable.

*If the files were in the same directory wildcards allow for a more efficient solution.

data_null__
Jade | Level 19

You could save yourself some time by looking at the examples in the online documentation.

kaushal2040
Calcite | Level 5

data_null_;

I was also looking at the video of power of call execute.  I still don't think I can use in my case.  So getting insights from SAS gurus

Thanks !!!

Reeza
Super User

If you have a specific case in mind, you should ask that case. There are always so many alternatives beyond even call execute and macros. In fact, I go out of my way to avoid both in most cases.

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
  • 6 replies
  • 1042 views
  • 6 likes
  • 3 in conversation