DATA Step, Macro, Functions and more

Macro create aggregate file at the first itteration of a group

Reply
Super Contributor
Posts: 371

Macro create aggregate file at the first itteration of a group

Hi Everyone,

My data is like that:

period     day     var1     var2...

Each period has many days and I make day index variable (1 to n for the whole dataset)

I make a macro to analyze data for each Day and combine daily result into a Period_file.

Since there is no rule for when is the first day of the period, I don't know how to tell SAS that, create a new Peirod_file when start new group of iteration.

It should be something like that

Data Summary_.

     if (START of new start/end group) %then %do;
          set daily;
          %end;
     %else %do;
          set Summary_&period      daily;
          %end;

run;

Thank you so much for your help.

HHC

The whole sample code is like that:

%macro test (start,end,period);
    %do i=&start %to &end;
           data Temp_&i;      set mydata;
           if day= &i;  run;
*ANALYSIS SECTION FOR EACH Period FILE; there will be 01 summary file per period;
Proc means noprint;
var  var1;
output out=daily
N=N;run;

Data Summary_.

if (START of new start/end group) %then %do;
set daily;
%end;
%else %do;
set Summary_&period daily;
%end;

run;

   %end;
%mend test;
%test (1,50,1);
%test (51,65,2);

Super User
Posts: 5,256

Re: Macro create aggregate file at the first itteration of a group

Hard to follow your requirement.

Please attach some sample input and desired output data.

Data never sleeps
Super Contributor
Posts: 371

Re: Macro create aggregate file at the first itteration of a group

Sorry for not making it clear.

I'll get back to this issue later.

Thank you,

HHC

Ask a Question
Discussion stats
  • 2 replies
  • 211 views
  • 0 likes
  • 2 in conversation