|
I assume, the number of grouüps is dynamic. So the first thing is to
extract the group IDs and their number.
proc sort data=dt(keep=id) out=grps nodupkey force;
by id;
run;
%let gno=0;
data _null_;
set grps;
call symput("gno",_n_);
call symput("id"!!put(_n_,8 -l),id);
run;
now you have all the information for your macro and the internal loops.
%macro doit;
%do i=1 %to &gno;
.....
the ids you acces by: &&id&i
....
the file-numbers for the excel files you generate by
... "file&i..xls"
%mend;
Gerhard
On Sun, 8 Jun 2008 22:33:36 -0700, Bill Johnson <belfry2688@MYPACKS.NET>
wrote:
>Hi Everyone,
>
>Long time reader, first time poster.
>
>I have 1 dataset that contains N groups (in long format) and I'm
preparing data to be processed by an external program.
>
>For each group, I'd like to:
> -write their data to an Excel file
> -call a macro with that subgroups ID#
>
>So, if I have 3 groups, I'd like to:
>
>-save excel to 'file1.xls'
>-call myMacro(1)
>
>iterate...
>
>-save excel to 'file3.xls'
>-call myMacro(3)
>
>-finish.
>
>How would I do that?
>
>Thanks,
>Bill
|