What is the difference between specifying CALL EXECUTE at first iteration and not specifying any interation at all?
data test; call execute('proc print data=sashelp.class;run;'); run; data test; if _n_=1 then call execute('proc print data=sashelp.class;run;'); run;
I was referring to "The" documentation. https://support.sas.com/documentation/cdl/en/lefunctionsref/67960/HTML/default/viewer.htm#p1blnvlvci...
But I realize that %NRSTR is not mentioned.
I believe Roland's explanation of the issue is adequate. Here is the link to the SAS-L tread where he learnt how CALL EXECUTE works. https://listserv.uga.edu/cgi-bin/wa?A2=ind1210c&L=SAS-L&D=0&X=83E8E1025408227B5F&Y=datanull%40gmail....
Not a lot. If you have a data step, with no set clause like that, an empty observation is created, hence because there is one observation the call execute gets executed exactly once. In your second example, exactly the same thing happens, one blank observation is create and it has _n_=1, so call execute happens once also.
Notice that both data steps produce the same data set output.
NOTE: The data set WORK.TEST has 1 observations and 0 variables.
I've yet to find a use for that. 🙂 Although a 0 obs 0 vars can be useful.
Probably a case for
data _null_;
makes you look you know what you're doing.
@RW9 @data_null__. Thank you. The other thing that baffles me when the argument of CALL EXECUTE is some macro. CALL EXECUTE sends its argument to macro processor for execution. Doesn't macro code go to macro processor without the need of CALL EXECUTE?
Macro code or a macro call is executed immediately by CALL EXECUTE any code emitted by calling a macro or code written directly by CALL EXECUTE is "stacked" for execution after the data step that is doing the CALL EXECUTEing is done. This is subtle difference between calling a macro the "regular way" vs EXECUTE and not well understood by most users.
See the bit about %NRSTR in the documentation.
Do note, I generally avoid using the two together, there is really no need, they both do a similar job at the end of the day, so its simpler to choose one or the other approach. That being said, 90% of the time you don't need to use either, Base SAS can do most things.
@RW9 You wrote "Do note, I generally avoid using the two together".
two means CALL EXECUTE and Macro?
I really want to expand my sas skills horizon that's why I want to learn useful new technique if there is. I have found people using CALL EXECUTE in their program.I have not used it in my program yet. But curious if I can use in my case.
Yes, only use one method to generate code, either macro or call execute. They both have their benefits and drawbacks, but ultimately do a similar thing.
Its really down to what the code is to be used for. If its a one off program, then use Base SAS which can basically do 99% of things, and if you really need to repeat code, use call execute. If you need reusable code, then macro is probably better.
I was referring to "The" documentation. https://support.sas.com/documentation/cdl/en/lefunctionsref/67960/HTML/default/viewer.htm#p1blnvlvci...
But I realize that %NRSTR is not mentioned.
I believe Roland's explanation of the issue is adequate. Here is the link to the SAS-L tread where he learnt how CALL EXECUTE works. https://listserv.uga.edu/cgi-bin/wa?A2=ind1210c&L=SAS-L&D=0&X=83E8E1025408227B5F&Y=datanull%40gmail....
@data_null__. Thank you.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.