Date: Wed, 15 May 2002 11:35:13 -0700
Reply-To: Dale McLerran <stringplayer_2@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Dale McLerran <stringplayer_2@YAHOO.COM>
Subject: Re: proc runs too fast
In-Reply-To: <200205151635.g4FGZ3h23990@listserv.cc.uga.edu>
Content-Type: text/plain; charset=us-ascii
--- Gerhard Hellriegel <ghellrieg@T-ONLINE.DE> wrote:
> On Wed, 15 May 2002 12:03:12 -0400, Karen Olson, Ph.D.
> Note that a macro resolves to SAS code **before** that code is
> executed. So if you produce 1000 PROC SURVEYSELECTs in a macro,
> that 1000 PROCs will be created, as if you had keyed them in in
> the editor and **after** that they will be executed! So the macro
> resolution may last 1h or 10h, that has no influence to the PROC
> SURVEYSELECTs
Hmm. I don't believe that this is correct, either about how the
macro processor and main SAS processor work together or about what
the consequence would be if your understanding of the macro/SAS
interaction were true. First, consider a situation in which we have
a macro loop, and inside the loop is a datastep which obtains some
information which is written to a macro variable and which controls
subsequent processing. Look at the following code:
data conditions;
input cond;
cards;
<
=
>
;
%macro condit;
local i ncondit condit;
/* determine the number of conditions in the above dataset */
data _null_;
if 0 then set conditions nobs=ncondit;
call symput("ncondit", put(ncondit, 4. -L));
stop;
run;
%do i=1 %to &ncondit;
/* Write i-th condition to macro variable */
data _null_;
set conditions point=&i;
call symput("condit", condit);
run;
/* Execute the procedure employing the i-th condition */
proc whatever data=xyz(where=(x&condit.y));
run;
%end;
%mend;
Note that in the above code, one would not be able to construct the
procedure code for the i-th loop until the i-th loop is executed.
Loop i+1 cannot execute until loop i has executed. Macro code
execution does not occur without some preceeding datastep execution.
So, I don't believe that your statement of how the procedure code
is constructed is correct. Within a loop, the procedure code for
the i-th iteration of the loop is not constructed until the i-th
loop is executed. That can be a log way into the execution of a
macro.
Now, even if you were correct about how the procedure code is
constructed, your inference about how SURVEYSELECT would operate is
incorrect. In the case at hand, every one of the procedure steps
does get constructed in the same manner, so that 1000 instances of
PROC SURVEYSELECT with SEED=0 could be constructed at macro compile
time. Now, suppose that each instance of SURVEYSELECT occured at
5 minute intervals. When SEED=0 is employed for initializing a seed
stream, the wall clock time at the time of procedure execution is
employed to initialize the seed stream. Since the wall clock time
is indeed different at 5 minute intervals, then the seed stream for
each instance of the SURVEYSELECT procedure will be different, and
the procedure will return different samples.
> If you want to have a gap between that PROCs, you should add some
> executable (not macro!!) code, e.g. a DATA-step. In that datastep you
> might
> use the sleep-function
>
> data _null_;
> x=sleep(1,1);
> run;
>
> that will wait for a second (the second argument is the unit, e.g.
> 0.1
> means 1/10 sec)
Yes, I would agree that if you want to eat up some time, then it is
better to use non-macro code for the purpose. However, for the
purpose of returning different random samples from a dataset,
slowing down the execution of your program is not the appropriate
way to go. Rather, the best approach is to actually exert control
over the seed stream, as has been mentioned in other posts on this
subject.
Dale
=====
---------------------------------------
Dale McLerran
Fred Hutchinson Cancer Research Center
mailto: dmclerra@fhcrc.org
Ph: (206) 667-2926
Fax: (206) 667-5977
---------------------------------------
__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com