Date: Tue, 9 Jan 2007 12:32:01 -0500
Reply-To: "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Subject: Re: tip: Whitlock do-loop (DOW) and call execute
"Fehd, Ronald J. (CDC/CCHIS/NCPHI)" wrote:
> I am always on the alert to avoid having to do extra work
> to make-unique using either
> * freq
> * sort
> * sql
> to produce a list-processing -- aka dynamic programming --
> data set to be used to generate reports.
>
> violet! DOW to the rescue:
>
> %macro report(region=);
> %Put reg<&Reg.>;
> %mend;
>
> DATA _Null_;
> do until(EndoFile);
> do until(Last.Region);
> set sashelp.Shoes
> end = EndoFile;
> by Region;
> end;
> call execute('%report(region=' !! trim(Region) !! ')' );
> end;
> stop;
> run;
> run;
>
It many cases it is best to delay the actual execution of the 'desired to be
executed' macro until after the data step completes.
Such is done by wrapping the macro invocation in a %nrstr
dispatch = cats ('%report(region=',region,')');
delayed_dispatch = cats ('%nrstr(',dispatch,')');
call execute (delayed_dispatch);
I don't see where the DOW contributes to the dispatching process. A simpler
form would suffice.
set sashelp.shoes;
if last.region;
... dispatch ...
run;
--
Richard A. DeVenezia
http://www.devenezia.com/