Ron Fehd has been presenting at NESUG for
many
years and he'll be with us again this year. We can
always rely on him for helpful information and we can
usually spot him wearing his signature purple hat.
Here is a tip from him about using CALL EXECUTE
with %
nrstr.
The call routine Execute is used to submit
statements. Its arguments can be text strings or
variable values.
It replaces the process of writing statements to a file,
then %including them.
Example, Write to File, then Include:
Filename TempText 'tempfile.txt';
Data _Null_;
file TempText;
put '*comment;';
stop;
run;
%Include TempText;
The syntax of call execute is:
* string: call execute('*comment;');
* character variable:
Stmnt = '*comment;';
call execute(Stmnt);
Caveat: sas and macro statements are different!
When a macro contains complexity, that is, any macro
statements which accesses or creates macro
variables, such as %if, %do, or call symput, then the
macro will not resolve correctly.
Solution: use macro function No Rescan String: %nrstr
Data _Null_;
attrib Stmnt length = $72;
do until(EndoFile);
set MyListProccesingDataSet
end = EndoFile;
%*make statement:;
call execute(cats('%nrstr(',Stmnt,')'));
end; %*do until(EndoFile);
stop;
run; %*calls executed in this step;
run;
sgf2007.113 provides examples which illustrate the
timing error.
nesug2007.CC12 provides working examples of
using call execute to call
either parameterized includes or macros.
References:
sgf2007.113:
List Processing Basics:
Creating and Using Lists of Macro Variables
Ronald J. Fehd and Art Carpenter
nesug2007.CC12
Writing Testing-Aware Programs that Self-Report
when Options are True
Ronald J. Fehd