Date: Wed, 6 Aug 1997 07:57:55 GMT
Reply-To: Victor Bos <Victor.Bos@NL.ORIGIN-IT.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Victor Bos <Victor.Bos@NL.ORIGIN-IT.COM>
Organization: Origin
Subject: Macro problem (caused by memory leak?)
Hello everybody,
During the development of a quite complex macro I noticed that the running
time of that macro increased each time I submitted it. When I tried to find
out how this is caused, I noticed that the resolving of macrovariables
takes more and more time at each invocation. The following simple program
shows the problem:
%macro q;
data _null_;
call symput ('t', time ());
run;
%do i = 1 %to 100;
%let j = %lowcase (&i);
%end;
data _null_;
t = time () - &t;
put t=;
run;
%mend;
%q;
If you run the %q macro, say 50 times, you'll see time t increase. I tried
it on an RS/6000 machine running AIX (SAS 6.12), a DEC Alpha running VMS
(SAS 6.09), and Windows95 (SAS 6.12). The problem seems to exist at all
those operating systems, although the problem seems to be less big on
Windows95, as the time seems not only to increase, but also decrease in
subsequent invocations.
My question is: has anyone of you encountered this problem? Perhaps on
other operating systems?
Victor Bos,
Origin /Business Management Solutions.
PS: Another thing I noticed is that if you replace the %lowcase in the
program above by %upcase, the program runs much, much faster. This is
explainable as %upcase is a macro function, and %lowcase is an autocall
macro provided by SAS. So a good programming habit is to use %upcase
instead of %lowcase in macros if possible.